Package edu.cnu.mdi.util
Class MathUtils
java.lang.Object
edu.cnu.mdi.util.MathUtils
General mathematical helpers used by drawable geometry.
-
Method Summary
Modifier and TypeMethodDescriptionstatic doubleperpendicularIntersection(double x1, double y1, double x2, double y2, Point2D.Double wp, Point2D.Double pintersect) Given two points p0 and p1, imagine a line from p0 to p1.
-
Method Details
-
perpendicularIntersection
public static double perpendicularIntersection(double x1, double y1, double x2, double y2, Point2D.Double wp, Point2D.Double pintersect) Given two points p0 and p1, imagine a line from p0 to p1. Take the line to be parameterized by parameter t so that at t = 0 we are at p0 and t = 1 we are at p1.- Parameters:
x1- x coordinate of one endpointy1- y coordinate of one endpointx2- x coordinate of other endpointy2- y coordinate of other endpointwp- the point from which we drop a perpendicular to p0 -> p1pintersect- the intersection point of the perpendicular and the line containing p0-p1. It may or may not actually be between p0 and p1, as specified by the return argument.- Returns:
- the value of the t parameter. If it is between 0 and 1 the intersection is on the line. If t less than 0 the intersection is on the "infinite line" but not on p0->p1, it is on the p0 side. If t > 1 the intersection is on the p1 side.
-