Examples of squaredNorm()


Examples of jinngine.math.Vector3.squaredNorm()

    }

    @Test
    public void testSquareNorm() {
        final Vector3 a = new Vector3(1., 2., 3.);
        a.squaredNorm();
        assertEquals(1., a.x);
        assertEquals(2., a.y);
        assertEquals(3., a.z);
        assertEquals(1029., new Vector3(32., 1., 2.).squaredNorm());
        assertEquals(1029., new Vector3(2., 32., 1.).squaredNorm());
View Full Code Here

Examples of jinngine.math.Vector3.squaredNorm()

    //  t =  xT(p2-p1) - p1T(p2-p1) / (p2-p1)T(p2-p1)
    //  t =  (x-p1)T(p2-p1) / |(p2-p1)|^2

    final Vector3 p2p1 = p2.sub(p1);
    p2p1.z = 0; // we only work in the xy plane
    final double t = x.sub(p1).dot(p2p1) / p2p1.squaredNorm();
    if (t>= -epsilon && t <= 1+epsilon) {
      // closest point on line
      Vector3 lp = p1.add(p2.sub(p1).multiply(t));
      if lp.sub(x).xynorm() < epsilon ) {
        intPoint.assign(lp);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.