ch.epfl.scapetoad
Class Geometry

java.lang.Object
  extended by ch.epfl.scapetoad.Geometry

public class Geometry
extends java.lang.Object

Contains some static methods for geometrical computations.


Constructor Summary
Geometry()
           
 
Method Summary
static double areaOfQuadrangle(double ax, double ay, double bx, double by, double cx, double cy, double dx, double dy)
          Computes the area of an irregular quadrangle defined by the points A(ax, ay), B(bx, by), C(cx, cy) and D(dx, dy).
static double areaOfTriangle(double ax, double ay, double bx, double by, double cx, double cy)
          Computes the area of the triangle defined by the points A(ax, ay), B(bx, by) and C(cx, cy).
static double[] intersectionOfSegments(double ax, double ay, double bx, double by, double cx, double cy, double dx, double dy)
          Computes the intersection of two segments AB and CD.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Geometry

public Geometry()
Method Detail

areaOfTriangle

public static double areaOfTriangle(double ax,
                                    double ay,
                                    double bx,
                                    double by,
                                    double cx,
                                    double cy)
Computes the area of the triangle defined by the points A(ax, ay), B(bx, by) and C(cx, cy).

Parameters:
ax - the x coordinate of point A
ay - the y coordinate of point A
bx - the x coordinate of point B
by - the y coordinate of point B
cx - the x coordinate of point C
cy - the y coordinate of point C
Returns:
the area of the triangle ABC

areaOfQuadrangle

public static double areaOfQuadrangle(double ax,
                                      double ay,
                                      double bx,
                                      double by,
                                      double cx,
                                      double cy,
                                      double dx,
                                      double dy)
Computes the area of an irregular quadrangle defined by the points A(ax, ay), B(bx, by), C(cx, cy) and D(dx, dy). The four points must be following points in the quadrangle (clockwise or counter-clockwise). Therefore, point A can not be a neighbour of point C.

Parameters:
ax - the x coordinate of point A
ay - the y coordinate of point A
bx - the x coordinate of point B
by - the y coordinate of point B
cx - the x coordinate of point C
cy - the y coordinate of point C
dx - the x coordinate of point D
dy - the y coordinate of point D
Returns:
the area of the quadrangle ABCD

intersectionOfSegments

public static double[] intersectionOfSegments(double ax,
                                              double ay,
                                              double bx,
                                              double by,
                                              double cx,
                                              double cy,
                                              double dx,
                                              double dy)
Computes the intersection of two segments AB and CD.