Hi, ive got to make a program to find the perimeter and area of a triangle made using vectors, and i have not a clue, ill post the code i have done so far and if any1 could give me the code for the area and perimeter you would be life savers, thanks in advance.
public class Tri{
private Point VectorA;
private Point VectorB;
private Point VectorC;
private Point VectorD;
private double perimeter;
private double area;
public Tri(Point VectorA, Point VectorB, Point VectorC){
this.VectorA=VectorA;
this.VectorB=VectorB;
this.VectorC=VectorC;
this.VectorD=VectorD;
calculateperimeter();
calculatearea();
}
public void setVectorA (Point VectorA){
this.VectorA=VectorA;
calculateperimeter();
}
public Point getVectorA(){
return VectorA;
}
public void setVectorB (Point VectorB){
this.VectorB=VectorB;
calculateperimeter();
}
public Point getVectorB(){
return VectorB;
}
public void setVectorC (Point VectorC){
this.VectorC=VectorC;
calculateperimeter();
}
public Point getVectorC(){
return VectorC;
}
public void setVectorD (Point VectorD){
this.VectorD=VectorD;
calculateperimeter();
}
public Point getVectorD(){
return VectorD;
}
private void calculateperimeter(){
int perimeterx = VectorA.getX()-VectorB.getX();
int perimetery = VectorC.getY()-VectorD.getY();
perimeter=Math.sqrt ((perimeterx * perimeterx) + (perimetery * perimetery));
}
public double getperimeter(){
return perimeter;
}
private void calculatearea(){
int areax = VectorA.getX()-VectorB.getX();
int areay = VectorC.getY()-VectorD.getY();
area=Math.sqrt ((area * area) + (areax * areay));
}
public double getarea(){
return area;
}
}
as you can see the code is from my rectangle version of this program so it doesnt work completely :S