Hi this a part of my code : I have a list which its size is three and I consider that 2 last items are in one line (p and q) I need to get the angle between the first item of this list and these two points (p,q)
private Point partition(List<Point> list, Point p, Point q) {
double x1 = p.getX();
double x2 = q.getX();
double y1 = p.getY();
double y2 = q.getY();
double pQ = Math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
for (int i = 0; i < list.size()-2; i++) {
double pointX = list.get(i).getX();
double pointY = list.get(i).getY();
double pointQ = Math.sqrt((x2 - pointX) * (x2 - pointX) + (y2 - pointY) * (y2 - pointY));
double pointP = Math.sqrt((pointX - x1) * (pointX - x1) + (pointY - y1) * (pointY - y1));
double angle = Math.acos((pQ * pQ - pointP * pointP - pointQ * pointQ) /(- 2 * pointP * pointQ));
System.out.println(angle);
}
but instead of printing an angle for the first item it will print :(first item is not in the line of two last items).
1.6288442476732894
those points that print this result are :
[X :143.0 Y: 217.0, X :93.0 Y: 163.0, X :193.0 Y: 165.0]
please help me thanks.
EDITED : really it makes me confused .in such a way it will print this value ,sorry all !!!