JavaView® v2.00.008

jv.vecmath
Class PuVectorGeom

java.lang.Object
  |
  +--jv.vecmath.PuVectorGeom

public class PuVectorGeom
extends java.lang.Object

Static methods for vector geometry. Most methods work in euclidean vector spaces of arbitrary dimension.

Version:
03.10.99, 1.10 revised (kp) Renamed from PdVectorGeom to PuVectorGeom.
28.08.99, 1.00 revised (kp) Several beautifications.
28.08.99, 1.00 created (kp) Extracted from PdVector, methods made static.
Author:
Konrad Polthier

Constructor Summary
PuVectorGeom()
           
 
Method Summary
static boolean circleThruPoints(PdVector center, double radius, PdVector p, PdVector q, PdVector r)
          Compute circle through three given points.
static void ctg(double[] ctg, PdVector p, PdVector q, PdVector r)
          Compute cotanges of the vertex angles at all vertices of the triangle (p, q, r).
static double ctg(PdVector p, PdVector q1, PdVector q2)
          Compute cotanges of the vertex angle at vertex p in the triangle (p, q1, q2).
static double distOfLineToLine(PdVector base1, PdVector dir1, PdVector base2, PdVector dir2)
          Compute distance of line to line.
static double distOfPointToLine(PdVector p, PdVector base, PdVector dir)
          Compute distance of point to line.
static double distOfPointToPlane(PdVector p, PdVector base, PdVector normal)
          Compute distance of point to plane.
static double distVectorOfLineToLine(PdVector lot, PdVector base1, PdVector dir1, PdVector base2, PdVector dir2)
          Compute shortest distance vector of line to line.
static void distVectorOfPointToLine(PdVector lot, PdVector p, PdVector base, PdVector dir)
          Compute shortest distance vector of point to line.
static void distVectorOfPointToPlane(PdVector lot, PdVector p, PdVector base, PdVector normal)
          Compute shortest distance vector of point to plane.
static boolean evalCircle(PdVector p, PdVector mid, PdVector orient, PdVector start, PdVector end, double t)
          Compute a point between the two end points of a circle segment.
static boolean evalHelix(PdVector p, PdVector axisBot, PdVector axisDir, PdVector start, PdVector end, double t)
          Compute a point between the two end points of a segment of a helix.
static double intersectionOfLineAndLine(PdVector p, PdVector base1, PdVector dir1, PdVector base2, PdVector dir2)
          Check for intersection of line and line by solving equation b1+sd1 = b2+td2.
static double intersectionOfLineAndPlane(PdVector p, PdVector base1, PdVector dir, PdVector base2, PdVector normal)
          Compute intersection line and plane.
static boolean intersectionOfPlaneAndPlane(PdVector lineBase, PdVector lineDir, PdVector base1, PdVector normal1, PdVector base2, PdVector normal2)
          Compute intersection of plane and plane, and return the intersection line.
static void projectOntoLine(PdVector v, PdVector dir)
          Project a given vector to a line through the origin.
static void projectOntoLine(PdVector vProj, PdVector v, PdVector dir)
          Project a given vector to a line through the origin.
static void projectOntoPlane(PdVector v, PdVector normal)
          Project a given vector to a plane through the origin.
static void projectOntoPlane(PdVector vProj, PdVector v, PdVector normal)
          Project a given vector to a plane through the origin.
static void projectPointToCircle(PdVector proj, PdVector p, PdVector mid, PdVector normal, double radius)
          Project 3d-point onto circle in 3d by 1) project point onto plane of circle 2) adjust distance to mid point.
static void projectPointToLine(PdVector proj, PdVector p, PdVector base, PdVector dir)
          Project a given point to line.
static void projectPointToPlane(PdVector proj, PdVector p, PdVector base, PdVector normal)
          Project a given point to plane.
static boolean rotatePointAroundLine(PdVector pRot, PdVector p, PdVector axisBase, PdVector axisDir, double alpha)
          Rotate a point around an arbitrary axis by a given angle.
static boolean rotatePointAroundVector(PdVector pRot, PdVector p, PdVector axisDir, double alpha)
          Rotate a point around an axis through the origin by a given angle.
static double sphericalAngle(PdVector p, PdVector q1, PdVector q2)
          Compute spherical angle at vertex p or a triangle on the unit sphere in S^n.
static double sphericalArea(PdVector p, PdVector q, PdVector r)
          Compute area of a spherical triangle on the unit sphere in S^n.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PuVectorGeom

public PuVectorGeom()
Method Detail

intersectionOfLineAndLine

public static double intersectionOfLineAndLine(PdVector p,
                                               PdVector base1,
                                               PdVector dir1,
                                               PdVector base2,
                                               PdVector dir2)
Check for intersection of line and line by solving equation b1+sd1 = b2+td2. Multiply both sides with d1 and with d2 to obtain two scalar equations
    + s =  + t
    + s =  + t
   => s = d2>/(1.-**2)
 
Method works in euclidean vector spaces of arbitrary dimension.
Parameters:
p - computed intersection point
base1 - any point on the first line
dir1 - unit direction of first line
base2 - any point on the second line
dir2 - unit direction of second line
Returns:
double distance s from base1 to intersection point, or Double.MAX_VALUE if line and plane are parallel.

intersectionOfLineAndPlane

public static double intersectionOfLineAndPlane(PdVector p,
                                                PdVector base1,
                                                PdVector dir,
                                                PdVector base2,
                                                PdVector normal)
Compute intersection line and plane. Line is given by base point and direction, plane is given by base point and plane normal. The intersection point x=ray+s*dir on the line must fulfill plane equation = . Use this equation to derive a value for s by solving = leading to s = /. Direction of ray must be normalized, normal of plane need not be normalized.

Method works in euclidean vector spaces of arbitrary dimension.

Parameters:
p - computed intersection point
base1 - any point on the line
dir - unit direction of line
base2 - any point on the plane
normal - normal of plane, need not be normalized
Returns:
double distance s from base1 to intersection point, or Double.MAX_VALUE if line and plane are parallel.

intersectionOfPlaneAndPlane

public static boolean intersectionOfPlaneAndPlane(PdVector lineBase,
                                                  PdVector lineDir,
                                                  PdVector base1,
                                                  PdVector normal1,
                                                  PdVector base2,
                                                  PdVector normal2)
Compute intersection of plane and plane, and return the intersection line.

   lineDir parallel to n1xn2
   lineBase = s*n1 + t*n2.
 
Insert in both plane equations and solve for s and t:
    = 
    = 
   s + t = 
   s + t = 
   => s = (-)/(1.-**2)
   => t = (-)/(1.-**2)
 
Method only works in euclidean 3-space.
Parameters:
lineBase - computed point on the intersection line
lineDir - computed direction of the intersection line
base1, - base2 some points on each plane
normal1, - normal2 unit normals of each plane
Returns:
true if both planes intersect

distVectorOfPointToLine

public static void distVectorOfPointToLine(PdVector lot,
                                           PdVector p,
                                           PdVector base,
                                           PdVector dir)
Compute shortest distance vector of point to line.

Method works in euclidean vector spaces of arbitrary dimension.

Parameters:
lot - resulting distance vector
p - given point
base - some point of the line
dir - unit direction of the line
Returns:
distance
See Also:
projectPointToLine(jv.vecmath.PdVector, jv.vecmath.PdVector, jv.vecmath.PdVector, jv.vecmath.PdVector)

distVectorOfPointToPlane

public static void distVectorOfPointToPlane(PdVector lot,
                                            PdVector p,
                                            PdVector base,
                                            PdVector normal)
Compute shortest distance vector of point to plane.

Method works in euclidean vector spaces of arbitrary dimension.

Parameters:
lot - resulting distance vector
p - given point
base - some point on the plane
normal - unit normal of plane
See Also:
projectPointToPlane(jv.vecmath.PdVector, jv.vecmath.PdVector, jv.vecmath.PdVector, jv.vecmath.PdVector)

distVectorOfLineToLine

public static double distVectorOfLineToLine(PdVector lot,
                                            PdVector base1,
                                            PdVector dir1,
                                            PdVector base2,
                                            PdVector dir2)
Compute shortest distance vector of line to line. Method only works in euclidean 3-spaces.
Parameters:
lot - resulting distance vector
base1, - base2 some points on each line
dir1, - dir2 direction of each line
Returns:
distance of both lines, or Double.MAX_VALUE if parallel.
See Also:
distOfLineToLine(jv.vecmath.PdVector, jv.vecmath.PdVector, jv.vecmath.PdVector, jv.vecmath.PdVector)

distOfPointToLine

public static double distOfPointToLine(PdVector p,
                                       PdVector base,
                                       PdVector dir)
Compute distance of point to line. Use formula dist = |(p-base) x dir|.

Method works in euclidean vector spaces of arbitrary dimension.

Parameters:
p - given point
base - some point of the line
dir - direction of the line with unit length 1.
Returns:
distance of point to line, or Double.MAX_VALUE if line direction not normalized.

distOfPointToPlane

public static double distOfPointToPlane(PdVector p,
                                        PdVector base,
                                        PdVector normal)
Compute distance of point to plane. Use formula dist = .

Method works in euclidean vector spaces of arbitrary dimension.

Parameters:
p - given point
base - some point of the line
normal - unit normal of plane with length 1.
Returns:
distance

distOfLineToLine

public static double distOfLineToLine(PdVector base1,
                                      PdVector dir1,
                                      PdVector base2,
                                      PdVector dir2)
Compute distance of line to line. Use formula dist = ||/|dir1xdir2|. Special care is taken if directions are degenerate.

Currently, method works in euclidean 3-space only.

Parameters:
base1, - base2 some points on each line
dir1, - dir2 direction of each line
Returns:
distance

projectPointToLine

public static void projectPointToLine(PdVector proj,
                                      PdVector p,
                                      PdVector base,
                                      PdVector dir)
Project a given point to line. Use formula proj = base + dir. Point and projected point may be the same vector instances.

Method works in euclidean vector spaces of arbitrary dimension.

Parameters:
proj - projection of p to the line
p - given point
base - some point of the line
dir - unit direction of the line

projectPointToPlane

public static void projectPointToPlane(PdVector proj,
                                       PdVector p,
                                       PdVector base,
                                       PdVector normal)
Project a given point to plane. Use formula p - normal. Point and projected point may be the same vector instances.

Method works in euclidean vector spaces of arbitrary dimension.

Parameters:
proj - projection of p to the line
p - given point
base - some point of the plane
normal - unit normal of plane

projectPointToCircle

public static void projectPointToCircle(PdVector proj,
                                        PdVector p,
                                        PdVector mid,
                                        PdVector normal,
                                        double radius)
Project 3d-point onto circle in 3d by 1) project point onto plane of circle 2) adjust distance to mid point. Point and projected point may be the same vector instances.

Method works in euclidean vector spaces of arbitrary dimension.

Parameters:
proj - projection of p to the line
p - given point
base - some point of the plane
normal - unit normal of plane

projectOntoLine

public static void projectOntoLine(PdVector v,
                                   PdVector dir)
Project a given vector to a line through the origin. Use formula v = dir/|dir|^2.

Method works in euclidean vector spaces of arbitrary dimension.

Parameters:
v - given vector, also contains the result
dir - unit direction of the line

projectOntoLine

public static void projectOntoLine(PdVector vProj,
                                   PdVector v,
                                   PdVector dir)
Project a given vector to a line through the origin. Use formula vProj = dir/|dir|^2. Vector and projected vector may be the same vector instances.

Method works in euclidean vector spaces of arbitrary dimension.

Parameters:
vProj - projection of v to the line through the origin
v - given vector
dir - unit direction of the line

projectOntoPlane

public static void projectOntoPlane(PdVector v,
                                    PdVector normal)
Project a given vector to a plane through the origin. Use formula v = v-normal/|normal|^2.

Method works in euclidean vector spaces of arbitrary dimension.

Parameters:
v - given vector, also contains the result
normal - unit normal of the plane

projectOntoPlane

public static void projectOntoPlane(PdVector vProj,
                                    PdVector v,
                                    PdVector normal)
Project a given vector to a plane through the origin. Use formula vProj = v-normal/|normal|^2. Vector and projected vector may be the same vector instances.

Method works in euclidean vector spaces of arbitrary dimension.

Parameters:
vProj - projection of v to the plane through the origin
v - given vector
normal - unit normal of the plane

circleThruPoints

public static boolean circleThruPoints(PdVector center,
                                       double radius,
                                       PdVector p,
                                       PdVector q,
                                       PdVector r)
Compute circle through three given points. Use formula dist = ||/|dir1xdir2|.

Method works in euclidean vector spaces of arbitrary dimension.

Parameters:
center - resulting center of circle
radius - resulting radius of circle
p, - q, r three given points
Returns:
true if circle could be computed.

evalCircle

public static boolean evalCircle(PdVector p,
                                 PdVector mid,
                                 PdVector orient,
                                 PdVector start,
                                 PdVector end,
                                 double t)
Compute a point between the two end points of a circle segment. The three points mid, start and end determine the plane of the circle. The vector orient determines the orientation of the circle segment from start to end, i.e. how to run around the circle. The value t specifies the relative position on the segment, t=0 corresponds to start and t=1 corresponds to end.

Method only works in euclidean 3-space.

Parameters:
p - calculated point on circle segment
mid - center of circle
orient - normal vector determines which angle to take
start - first point on circle segment
end - second point on circle segment
t - relative position in [0.,1.] between start and end on segment
Returns:
true if circle could be evaluated.
See Also:
PdVector.angleWithOrientation(PdVector, PdVector, PdVector), rotatePointAroundLine(PdVector, PdVector, PdVector, PdVector, double)

evalHelix

public static boolean evalHelix(PdVector p,
                                PdVector axisBot,
                                PdVector axisDir,
                                PdVector start,
                                PdVector end,
                                double t)
Compute a point between the two end points of a segment of a helix. The point axisBot and direction axisDir determine an axis which generates a helix when rotating and translating the point start around the axis to the point end. The value t specifies the relative position on the segment, t=0 corresponds to start and t=1 corresponds to end.

Method only works in euclidean 3-space.

Parameters:
p - calculated point on helix segment
axisBot - point on axis of helix
axisDir - unit direction of axis of helix
start - first point on helix
end - second point on helix
t - relative position in [0.,1.] between start and end on segment
Returns:
true if helix could be evaluated.
See Also:
PdVector.angleWithOrientation(PdVector, PdVector, PdVector), rotatePointAroundLine(PdVector, PdVector, PdVector, PdVector, double)

rotatePointAroundVector

public static boolean rotatePointAroundVector(PdVector pRot,
                                              PdVector p,
                                              PdVector axisDir,
                                              double alpha)
Rotate a point around an axis through the origin by a given angle.

Method only works in euclidean 3-space.

Parameters:
pRot - rotated point
p - point to rotate
axisDir - unit direction of rotation axis through origin
alpha - rotation angle
Returns:
true if rotation could be performed.
See Also:
rotatePointAroundLine(PdVector,PdVector,PdVector,PdVector,double)

rotatePointAroundLine

public static boolean rotatePointAroundLine(PdVector pRot,
                                            PdVector p,
                                            PdVector axisBase,
                                            PdVector axisDir,
                                            double alpha)
Rotate a point around an arbitrary axis by a given angle. Axis need not go through the origin.

Method only works in euclidean 3-space.

Parameters:
pRot - rotated point
p - point to rotate
axisBase - some point on the rotation axis
axisDir - unit direction of rotation axis
alpha - rotation angle
Returns:
true if rotation could be performed.
See Also:
rotatePointAroundVector(PdVector,PdVector,PdVector,double)

ctg

public static double ctg(PdVector p,
                         PdVector q1,
                         PdVector q2)
Compute cotanges of the vertex angle at vertex p in the triangle (p, q1, q2).

Method works in euclidean vector spaces of arbitrary dimension.

Parameters:
p - vertex where to compute the cotanges
q1, - q2 other vertices of the triangle
Returns:
cotanges of vertex angle
See Also:
ctg(double[],PdVector,PdVector,PdVector)

ctg

public static void ctg(double[] ctg,
                       PdVector p,
                       PdVector q,
                       PdVector r)
Compute cotanges of the vertex angles at all vertices of the triangle (p, q, r).

Method works in euclidean vector spaces of arbitrary dimension.

Parameters:
ctg - cotangens of all vertex angles
p, - q, r vertices of the triangle
See Also:
ctg(PdVector,PdVector,PdVector), PuMath.ctg(double[],double,double,double)

sphericalAngle

public static double sphericalAngle(PdVector p,
                                    PdVector q1,
                                    PdVector q2)
Compute spherical angle at vertex p or a triangle on the unit sphere in S^n. All vertices must lie on a unit sphere, i.e. they must have unit length.

Method works in euclidean vector spaces of arbitrary dimension.

Parameters:
p - vertex where to compute the angle
q1, - q2 other vertices of the triangle
Returns:
spherical vertex angle at p
See Also:
PdVector.angle(PdVector,PdVector,PdVector)

sphericalArea

public static double sphericalArea(PdVector p,
                                   PdVector q,
                                   PdVector r)
Compute area of a spherical triangle on the unit sphere in S^n. All vertices must lie on a unit sphere, i.e. they must have unit length.

Method works in euclidean vector spaces of arbitrary dimension.

Parameters:
p, - q, r vertices of the triangle
Returns:
area of the spherical triangle
See Also:
sphericalAngle(PdVector,PdVector,PdVector)

JavaView® v2.00.008

The software JavaView® is copyright protected. All Rights Reserved.