Class PuVectorGeom
- java.lang.Object
-
- jv.vecmath.PuVectorGeom
-
public class PuVectorGeom extends java.lang.ObjectStatic methods for vector geometry. Most methods work in Euclidean vector spaces of arbitrary dimension.- Author:
- Konrad Polthier
- Version:
- 17.10.01, 1.30 revised (ep) Method added that calculates a sequence of rotations around y-,x-,z-axis
to transform a given frame to the standard Euclidean frame.
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.
-
-
Constructor Summary
Constructors Constructor and Description PuVectorGeom()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method and Description static booleancircleThruPoints(PdVector center, double radius, PdVector p, PdVector q, PdVector r)Compute circle through three given points.static voidctg(double[] ctg, PdVector p, PdVector q, PdVector r)Compute cotangent of the vertex angles at all vertices of the triangle (p, q, r).static doublectg(PdVector p, PdVector q1, PdVector q2)Compute cotangent of the vertex angle at vertex p in the triangle (p, q1, q2).static doubledistOfLineToLine(PdVector base1, PdVector dir1, PdVector base2, PdVector dir2)Compute distance of line to line.static doubledistOfPointToLine(PdVector p, PdVector base, PdVector dir)Compute distance of point to line.static doubledistOfPointToPlane(PdVector p, PdVector base, PdVector normal)Compute distance of point to plane.static doubledistVectorOfLineToLine(PdVector lot, PdVector base1, PdVector dir1, PdVector base2, PdVector dir2)Compute shortest distance vector of line to line.static voiddistVectorOfPointToLine(PdVector lot, PdVector p, PdVector base, PdVector dir)Compute shortest distance vector of point to line.static voiddistVectorOfPointToPlane(PdVector lot, PdVector p, PdVector base, PdVector normal)Compute shortest distance vector of point to plane.static booleanevalCircle(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 booleanevalHelix(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[]frameToStandardFrame(PdVector first, PdVector second, PdVector third)Computes the necessary rotations around the y, x and z axis, to transform a given orthonormal frame into the standard basis of R^3.static doubleintersectionOfLineAndLine(PdVector p, PdVector base1, PdVector dir1, PdVector base2, PdVector dir2)Check for intersection of line and line by solving equationb1+sd1 = b2+td2.static doubleintersectionOfLineAndPlane(PdVector p, PdVector base1, PdVector dir, PdVector base2, PdVector normal)Compute intersection line and plane.static booleanintersectionOfPlaneAndPlane(PdVector lineBase, PdVector lineDir, PdVector base1, PdVector normal1, PdVector base2, PdVector normal2)Compute intersection of plane and plane, and return the intersection line.static voidprojectOntoLine(PdVector v, PdVector dir)Project a given vector to a line through the origin.static voidprojectOntoLine(PdVector vProj, PdVector v, PdVector dir)Project a given vector to a line through the origin.static voidprojectOntoPlane(PdVector v, PdVector normal)Project a given vector to a plane through the origin.static voidprojectOntoPlane(PdVector vProj, PdVector v, PdVector normal)Project a given vector to a plane through the origin.static voidprojectPointToCircle(PdVector proj, PdVector p, PdVector mid, PdVector normal, double radius)Project 3d-point onto circle in 3d by project point onto plane of circle adjust distance to mid point.static voidprojectPointToLine(PdVector proj, PdVector p, PdVector base, PdVector dir)Project a given point to line.static voidprojectPointToPlane(PdVector proj, PdVector p, PdVector base, PdVector normal)Project a given point to plane.static booleanrotatePointAroundLine(PdVector pRot, PdVector p, PdVector axisBase, PdVector axisDir, double alpha)Rotate a point around an arbitrary axis by a given angle.static booleanrotatePointAroundVector(PdVector pRot, PdVector p, PdVector axisDir, double alpha)Rotate a point around an axis through the origin by a given angle.static doublesphericalAngle(PdVector p, PdVector q1, PdVector q2)Compute spherical angle at vertex p or a triangle on the unit sphere in S^n.static doublesphericalArea(PdVector p, PdVector q, PdVector r)Compute area of a spherical triangle on the unit sphere in S^n.
-
-
-
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 equationb1+sd1 = b2+td2. Multiply both sides with d1 and with d2 to obtain two scalar equations
Method works in Euclidean vector spaces of arbitrary dimension.<b1,d1> + s = <b2,d1> + t<d2,d1> <b1,d2> + s<d1,d2> = <b2,d2> + t => s = <b2-b1, d1-<d1,d2>d2>/(1.-<d1,d2>**2)- Parameters:
p- computed intersection pointbase1- any point on the first linedir1- unit direction of first linebase2- any point on the second linedir2- unit direction of second line- Returns:
- double distance
sfrom base1 to intersection point, or Double.MAX_VALUE if line and plane are parallel. - Author:
- Konrad Polthier
- Version:
- 04.03.01, 1.15 revised (kp) Return value changed to double from boolean.
28.08.99, 1.10 revised (kp) Several beautifications.
-
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<n, x> = <n, b2>. Use this equation to derive a value forsby solving<n, b1+sd> = <n,b2>leading tos = <n, b2-b1>/<n, d>. 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 pointbase1- any point on the linedir- unit direction of linebase2- any point on the planenormal- normal of plane, need not be normalized- Returns:
- double distance
sfrom base1 to intersection point, or Double.MAX_VALUE if line and plane are parallel. - Author:
- Konrad Polthier
- Version:
- 28.08.99, 1.10 revised (kp) Several beautifications.
-
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:
Method only works in Euclidean 3-space.<n1, sn1 + tn2> = <n1, b1> <n2, sn1 + tn2> = <n2, b2> s + t<n1,n2> = <n1,b1> s<n1,n2> + t = <n2,b2> => s = (<n1,b1>-<n2,b2><n1,n2>)/(1.-<n1,n2>**2) => t = (<n2,b2>-<n1,b1><n1,n2>)/(1.-<n1,n2>**2)- Parameters:
lineBase- computed point on the intersection linelineDir- computed direction of the intersection linebase1- base point of plane1base2- base point of plane2normal1- unit normal of plane1normal2- unit normal of plane2- Returns:
- true if both planes intersect
- Author:
- Konrad Polthier
- Version:
- 28.08.99, 1.10 revised (kp) Several beautifications.
-
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 vectorp- given pointbase- some point of the linedir- unit direction of the line- See Also:
projectPointToLine(jv.vecmath.PdVector, jv.vecmath.PdVector, jv.vecmath.PdVector, jv.vecmath.PdVector)- Author:
- Konrad Polthier
- Version:
- 28.08.99, 1.10 revised (kp) Several beautifications.
-
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 vectorp- given pointbase- some point on the planenormal- unit normal of plane- See Also:
projectPointToPlane(jv.vecmath.PdVector, jv.vecmath.PdVector, jv.vecmath.PdVector, jv.vecmath.PdVector)- Author:
- Konrad Polthier
- Version:
- 28.08.99, 1.10 revised (kp) Several beautifications.
-
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 vectorbase1- base point of line1base2- base point of line2dir1- direction of line1dir2- direction of line2- 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)- Author:
- Konrad Polthier
- Version:
- 28.08.99, 1.10 revised (kp) Several beautifications.
-
distOfPointToLine
public static double distOfPointToLine(PdVector p, PdVector base, PdVector dir)
Compute distance of point to line. Use formuladist = |(p-base) x dir|.Method works in Euclidean vector spaces of arbitrary dimension.
- Parameters:
p- given pointbase- some point of the linedir- direction of the line with unit length 1.- Returns:
- distance of point to line, or Double.MAX_VALUE if line direction not normalized.
- Author:
- Konrad Polthier
- Version:
- 15.09.10, 1.20 revised (fk) Avoid PdVector.subNew.
18.07.00, 1.10 revised (kp) Return Double.MAX_VALUE if line direction not normalized.
28.08.99, 1.00 revised (kp) Several beautifications.
-
distOfPointToPlane
public static double distOfPointToPlane(PdVector p, PdVector base, PdVector normal)
Compute distance of point to plane. Use formuladist = <p-base, normal>, that means, we use the signed distance which is positive if p lies in direction of the normal.Method works in Euclidean vector spaces of arbitrary dimension.
- Parameters:
p- given pointbase- some point of the linenormal- unit normal of plane with length 1.- Returns:
- distance signed distance is positive if p is in direction of normal
- Author:
- Konrad Polthier
- Version:
- 15.09.10, 1.30 revised (fk) Avoid PdVector.subNew.
05.09.02, 1.20 revised (kp) Return signed distance as written in documentation.
18.07.00, 1.10 revised (kp) Return Double.MAX_VALUE if line direction not normalized.
28.08.99, 1.00 revised (kp) Several beautifications.
-
distOfLineToLine
public static double distOfLineToLine(PdVector base1, PdVector dir1, PdVector base2, PdVector dir2)
Compute distance of line to line. Use formuladist = |<base1-base2, dir1xdir2>|/|dir1xdir2|. Special care is taken if directions are degenerate.Currently, method works in Euclidean 3-space only.
- Parameters:
base1- base point of line1base2- base point of line2dir1- direction of line1dir2- direction of line2- Returns:
- distance
- Author:
- Konrad Polthier
- Version:
- 02.12.00, 1.10 revised (kp) Catch degenerate directions.
28.08.99, 1.00 revised (kp) Several beautifications.
-
projectPointToLine
public static void projectPointToLine(PdVector proj, PdVector p, PdVector base, PdVector dir)
Project a given point to line. Use formulaproj = base + <p-base, dir>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 linep- given pointbase- some point of the linedir- unit direction of the line- Author:
- Konrad Polthier
- Version:
- 28.08.99, 1.00 revised (kp) Several beautifications.
-
projectPointToPlane
public static void projectPointToPlane(PdVector proj, PdVector p, PdVector base, PdVector normal)
Project a given point to plane. Use formulap - <p-base, normal>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 planep- given pointbase- some point of the planenormal- unit normal of plane- Author:
- Konrad Polthier
- Version:
- 28.08.99, 1.00 revised (kp) Several beautifications.
-
projectPointToCircle
public static void projectPointToCircle(PdVector proj, PdVector p, PdVector mid, PdVector normal, double radius)
Project 3d-point onto circle in 3d by- project point onto plane of circle
- adjust distance to mid point.
Method works in Euclidean vector spaces of arbitrary dimension.
- Parameters:
proj- projection of p to the linep- given pointmid- some point of the planenormal- unit normal of plane- Author:
- Konrad Polthier
- Version:
- 15.09.10, 1.10 revised (fk) Avoid PdVector.subNew.
28.08.99, 1.00 revised (kp) Several beautifications.
-
projectOntoLine
public static void projectOntoLine(PdVector v, PdVector dir)
Project a given vector to a line through the origin. Use formulav = <v,dir>dir/|dir|^2.Method works in Euclidean vector spaces of arbitrary dimension.
- Parameters:
v- given vector, also contains the resultdir- unit direction of the line- Author:
- Konrad Polthier
- Version:
- 28.08.99, 1.00 revised (kp) Several beautifications.
-
projectOntoLine
public static void projectOntoLine(PdVector vProj, PdVector v, PdVector dir)
Project a given vector to a line through the origin. Use formulavProj = <v,dir>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 originv- given vectordir- unit direction of the line- Author:
- Konrad Polthier
- Version:
- 28.08.99, 1.00 revised (kp) Several beautifications.
-
projectOntoPlane
public static void projectOntoPlane(PdVector v, PdVector normal)
Project a given vector to a plane through the origin. Use formulav = v-<v,normal>normal/|normal|^2.Method works in Euclidean vector spaces of arbitrary dimension.
- Parameters:
v- given vector, also contains the resultnormal- unit normal of the plane- Author:
- Konrad Polthier
- Version:
- 28.08.99, 1.00 revised (kp) Several beautifications.
-
projectOntoPlane
public static void projectOntoPlane(PdVector vProj, PdVector v, PdVector normal)
Project a given vector to a plane through the origin. Use formulavProj = v-<v,normal>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 originv- given vectornormal- unit normal of the plane- Author:
- Konrad Polthier
- Version:
- 28.08.99, 1.00 revised (kp) Several beautifications.
-
circleThruPoints
public static boolean circleThruPoints(PdVector center, double radius, PdVector p, PdVector q, PdVector r)
Compute circle through three given points. Use formuladist = |<base1-base2, dir1xdir2>|/|dir1xdir2|.Method works in Euclidean vector spaces of arbitrary dimension.
- Parameters:
center- resulting center of circleradius- resulting radius of circlep- given pointq- given pointr- given point- Returns:
trueif circle could be computed.- Author:
- Konrad Polthier
- Version:
- 28.08.99, 1.00 revised (kp) Several beautifications.
-
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 segmentmid- center of circleorient- normal vector determines which angle to takestart- first point on circle segmentend- second point on circle segmentt- 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)- Author:
- Konrad Polthier
- Version:
- 28.08.99, 1.00 revised (kp) Several beautifications.
-
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 segmentaxisBot- point on axis of helixaxisDir- unit direction of axis of helixstart- first point on helixend- second point on helixt- relative position in [0.,1.] between start and end on segment- Returns:
trueif helix could be evaluated.- See Also:
PdVector.angleWithOrientation(PdVector, PdVector, PdVector),rotatePointAroundLine(PdVector, PdVector, PdVector, PdVector, double)- Author:
- Konrad Polthier
- Version:
- 28.08.99, 1.00 revised (kp) Several beautifications.
-
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 pointp- point to rotate. May be equal to pRot.axisDir- unit direction of rotation axis through originalpha- rotation angle, in radians- Returns:
trueif rotation could be performed.- See Also:
rotatePointAroundLine(PdVector,PdVector,PdVector,PdVector,double)- Author:
- Konrad Polthier
- Version:
- 28.08.99, 1.00 revised (kp) Several beautifications.
-
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 pointp- point to rotateaxisBase- some point on the rotation axisaxisDir- unit direction of rotation axisalpha- rotation angle- Returns:
trueif rotation could be performed.- See Also:
rotatePointAroundVector(PdVector,PdVector,PdVector,double)- Author:
- Konrad Polthier
- Version:
- 28.08.99, 1.00 revised (kp) Several beautifications.
-
ctg
public static double ctg(PdVector p, PdVector q1, PdVector q2)
Compute cotangent 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 cotangentq1- other vertex of the triangleq2- other vertex of the triangle- Returns:
- cotangent of vertex angle
- See Also:
ctg(double[],PdVector,PdVector,PdVector)- Author:
- Konrad Polthier
- Version:
- 15.09.10, 1.10 revised (fk) Avoid PdVector.subNew.
28.08.99, 1.00 revised (kp) Several beautifications.
-
ctg
public static void ctg(double[] ctg, PdVector p, PdVector q, PdVector r)Compute cotangent of the vertex angles at all vertices of the triangle (p, q, r).Method works in Euclidean vector spaces of arbitrary dimension.
- Parameters:
ctg- cotangent of all vertex anglesp- vertex of the triangleq- vertex of the triangler- vertex of the triangle- See Also:
ctg(PdVector,PdVector,PdVector),PuMath.ctg(double[],double,double,double)- Author:
- Konrad Polthier
- Version:
- 28.08.99, 1.00 revised (kp) Several beautifications.
-
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 angleq1- other vertex of the triangleq2- other vertex of the triangle- Returns:
- spherical vertex angle at p
- See Also:
PdVector.angle(PdVector,PdVector,PdVector)- Author:
- Konrad Polthier
- Version:
- 28.08.99, 1.00 revised (kp) Several beautifications.
-
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- vertex of the triangleq- vertex of the triangler- vertex of the triangle- Returns:
- area of the spherical triangle
- See Also:
sphericalAngle(PdVector,PdVector,PdVector)- Author:
- Konrad Polthier
- Version:
- 28.08.99, 1.00 revised (kp) Several beautifications.
-
frameToStandardFrame
public static double[] frameToStandardFrame(PdVector first, PdVector second, PdVector third)
Computes the necessary rotations around the y, x and z axis, to transform a given orthonormal frame into the standard basis of R^3. The first vector of the frame is mapped to the x-axis, the second to the y-axis and so on.So if you want to get these rotation angles for e.g. the camera position, then you should call this method with normalized first = viewdir x upvector, second = upvector and third = -viewdir.
- Parameters:
first- First vector of frame becomes x-axis. FRAME MUST BE ORTHONORMAL! Orthonormality is not checked by this method!second- Second vector of frame becomes y-axis. See first.third- Third vector of frame becomes z-axis. See first.- Returns:
- Array of angles (RAD): angle to rotate around y-axis, around x-axis and around z-axis in this order.
- Author:
- Eike Preuß
- Version:
- 17.10.01, 1.00 created (ep)
-
-
"