public Point projectPoint(Point point, Point normal, double d) { double t = (point.dotProduct(normal) - d) / normal.dotProduct(normal); Point result = point.subtract(normal.multiply(t)); return result; }
public void pointDotProductTest() { double expected = 3; double a1 = 1.0; double a2 = 3.0; double a3 = -5.0; double b1 = 4.0; double b2 = -2.0; double b3 = -1.0; Point a = new Point(3); a.p[0] = a1; a.p[1] = a2; a.p[2] = a3; Point b = new Point(3); b.p[0] = b1; b.p[1] = b2; b.p[2] = b3; Assert.AreEqual(expected, a.dotProduct(b)); }
private Point projection(Point u, Point v) { Point result = null; result = u.multiply(u.dotProduct(v)/u.dotProduct(u)); return result; }