Package javax.vecmath

Examples of javax.vecmath.Vector3d.sub()


* Returns the square of the minimum distance from the given point to the segment
* defined by start, end.
*/
static final double ptToSegSquare(Point3d pt, Point3d start, Point3d end, Point3d closest) {
  Vector3d dir = new Vector3d();
  dir.sub(end, start);

  Vector3d dt = new Vector3d();
  dt.sub(pt, start);

  // Project the point onto the line defined by the segment
View Full Code Here


static final double ptToSegSquare(Point3d pt, Point3d start, Point3d end, Point3d closest) {
  Vector3d dir = new Vector3d();
  dir.sub(end, start);

  Vector3d dt = new Vector3d();
  dt.sub(pt, start);

  // Project the point onto the line defined by the segment
  double proj = dir.dot(dt);

  // We projected 'before' the start point, just return the dSquared between
View Full Code Here

  // If our point projected off the end of the segment, return the dSquared between
  // the point and the end
  if (proj >= segSquared) {
    if (closest != null) closest.set(end);
    dt.sub(pt, end);
    return dt.lengthSquared();
  }

  // We projected somewhere along the segment, calculate the closest point
  dt.scaleAdd(proj / segSquared, dir, start);
View Full Code Here

  // We projected somewhere along the segment, calculate the closest point
  dt.scaleAdd(proj / segSquared, dir, start);
  if (closest != null) closest.set(dt);

  // return the distance from the point to the closest point on the segment
  dt.sub(pt, dt);
  return dt.lengthSquared();
}

/**
* Returns the square of the minimum distance from the given point to the ray
View Full Code Here

* Returns the square of the minimum distance from the given point to the ray
* defined by start, dir.
*/
static final double ptToRaySquare(Point3d pt, Point3d start, Vector3d dir, Point3d closest) {
  Vector3d dt = new Vector3d();
  dt.sub(pt, start);

  // Project the point onto the ray
  double proj = dir.dot(dt);

  // We projected 'before' the start point, just return the dSquared between
View Full Code Here

  // We projected somewhere along the ray, calculate the closest point
  dt.scaleAdd(proj / raySquared, dir, start);
  if (closest != null) closest.set(dt);

  // return the distance from the point to the closest point on the ray
  dt.sub(pt, dt);
  return dt.lengthSquared();
}

private static final double ZERO_TOL = 1e-5d;
View Full Code Here

                                  Point3d segstart, Point3d segend,
                                  Point3d rayint, Point3d segint, double[] param) {
  double s, t;

  Vector3d diff = new Vector3d();
  diff.sub(rayorig, segstart);
  Vector3d segdir = new Vector3d();
  segdir.sub(segend, segstart);

  double A = raydir.dot(raydir);// Dot(ray.m,ray.m);
  double B = -raydir.dot(segdir);// -Dot(ray.m,seg.m);
View Full Code Here

  double s, t;

  Vector3d diff = new Vector3d();
  diff.sub(rayorig, segstart);
  Vector3d segdir = new Vector3d();
  segdir.sub(segend, segstart);

  double A = raydir.dot(raydir);// Dot(ray.m,ray.m);
  double B = -raydir.dot(segdir);// -Dot(ray.m,seg.m);
  double C = segdir.dot(segdir);// Dot(seg.m,seg.m);
  double D = raydir.dot(diff);// Dot(ray.m,diff);
View Full Code Here

                                      Point3d s1start, Point3d s1end,
                                      Point3d s0int, Point3d s1int, double[] param) {
  double s, t;

  Vector3d diff = new Vector3d();
  diff.sub(s0start, s1start);

  Vector3d seg0dir = new Vector3d();
  seg0dir.sub(s0end, s0start);
  Vector3d seg1dir = new Vector3d();
  seg1dir.sub(s1end, s1start);
View Full Code Here

  Vector3d diff = new Vector3d();
  diff.sub(s0start, s1start);

  Vector3d seg0dir = new Vector3d();
  seg0dir.sub(s0end, s0start);
  Vector3d seg1dir = new Vector3d();
  seg1dir.sub(s1end, s1start);

  double A = seg0dir.dot(seg0dir); // Dot(seg0dir,seg0dir);
  double B = -seg0dir.dot(seg1dir); // -Dot(seg0dir,seg1dir);
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.