public class PuVectorGeom
extends java.lang.Object
Constructor and Description |
---|
PuVectorGeom() |
Modifier and Type | Method and Description |
---|---|
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 cotangent of the vertex angles at all vertices of the triangle (p, q, r).
|
static double |
ctg(PdVector p,
PdVector q1,
PdVector q2)
Compute cotangent 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[] |
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 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.
|
public static double intersectionOfLineAndLine(PdVector p, PdVector base1, PdVector dir1, PdVector base2, PdVector dir2)
b1+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.+ s = + t + s = + t => s = d2>/(1.- **2)
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 lines
from base1 to intersection point,
or Double.MAX_VALUE if line and plane are parallel.public static double intersectionOfLineAndPlane(PdVector p, PdVector base1, PdVector dir, PdVector base2, PdVector normal)
=
. 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.
p
- computed intersection pointbase1
- any point on the linedir
- unit direction of linebase2
- any point on the planenormal
- normal of plane, need not be normalizeds
from base1 to intersection point,
or Double.MAX_VALUE if line and plane are parallel.public static boolean intersectionOfPlaneAndPlane(PdVector lineBase, PdVector lineDir, PdVector base1, PdVector normal1, PdVector base2, PdVector normal2)
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.= = s + t = s + t = => s = ( - )/(1.- **2) => t = ( - )/(1.- **2)
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 plane2true
if both planes intersectpublic static void distVectorOfPointToLine(PdVector lot, PdVector p, PdVector base, PdVector dir)
Method works in euclidean vector spaces of arbitrary dimension.
lot
- resulting distance vectorp
- given pointbase
- some point of the linedir
- unit direction of the lineprojectPointToLine(jv.vecmath.PdVector, jv.vecmath.PdVector, jv.vecmath.PdVector, jv.vecmath.PdVector)
public static void distVectorOfPointToPlane(PdVector lot, PdVector p, PdVector base, PdVector normal)
Method works in euclidean vector spaces of arbitrary dimension.
lot
- resulting distance vectorp
- given pointbase
- some point on the planenormal
- unit normal of planeprojectPointToPlane(jv.vecmath.PdVector, jv.vecmath.PdVector, jv.vecmath.PdVector, jv.vecmath.PdVector)
public static double distVectorOfLineToLine(PdVector lot, PdVector base1, PdVector dir1, PdVector base2, PdVector dir2)
lot
- resulting distance vectorbase1
- base point of line1base2
- base point of line2dir1
- direction of line1dir2
- direction of line2distOfLineToLine(jv.vecmath.PdVector, jv.vecmath.PdVector, jv.vecmath.PdVector, jv.vecmath.PdVector)
public static double distOfPointToLine(PdVector p, PdVector base, PdVector dir)
dist = |(p-base) x dir|
.
Method works in euclidean vector spaces of arbitrary dimension.
p
- given pointbase
- some point of the linedir
- direction of the line with unit length 1.public static double distOfPointToPlane(PdVector p, PdVector base, PdVector normal)
dist =
, 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.
p
- given pointbase
- some point of the linenormal
- unit normal of plane with length 1.public static double distOfLineToLine(PdVector base1, PdVector dir1, PdVector base2, PdVector dir2)
dist = ||/|dir1xdir2|
.
Special care is taken if directions are degenerate.
Currently, method works in Euclidean 3-space only.
base1
- base point of line1base2
- base point of line2dir1
- direction of line1dir2
- direction of line2public static void projectPointToLine(PdVector proj, PdVector p, PdVector base, PdVector dir)
proj = base + dir
.
Point and projected point may be the same vector instances.
Method works in euclidean vector spaces of arbitrary dimension.
proj
- projection of p to the linep
- given pointbase
- some point of the linedir
- unit direction of the linepublic static void projectPointToPlane(PdVector proj, PdVector p, PdVector base, PdVector normal)
p - normal
.
Point and projected point may be the same vector instances.
Method works in euclidean vector spaces of arbitrary dimension.
proj
- projection of p to the linep
- given pointbase
- some point of the planenormal
- unit normal of planepublic static void projectPointToCircle(PdVector proj, PdVector p, PdVector mid, PdVector normal, double radius)
Method works in euclidean vector spaces of arbitrary dimension.
proj
- projection of p to the linep
- given pointmid
- some point of the planenormal
- unit normal of planepublic static void projectOntoLine(PdVector v, PdVector dir)
v = dir/|dir|^2
.
Method works in euclidean vector spaces of arbitrary dimension.
v
- given vector, also contains the resultdir
- unit direction of the linepublic static void projectOntoLine(PdVector vProj, PdVector v, PdVector dir)
vProj = dir/|dir|^2
.
Vector and projected vector may be the same vector instances.
Method works in euclidean vector spaces of arbitrary dimension.
vProj
- projection of v to the line through the originv
- given vectordir
- unit direction of the linepublic static void projectOntoPlane(PdVector v, PdVector normal)
v = v-normal/|normal|^2
.
Method works in euclidean vector spaces of arbitrary dimension.
v
- given vector, also contains the resultnormal
- unit normal of the planepublic static void projectOntoPlane(PdVector vProj, PdVector v, PdVector normal)
vProj = v-normal/|normal|^2
.
Vector and projected vector may be the same vector instances.
Method works in euclidean vector spaces of arbitrary dimension.
vProj
- projection of v to the plane through the originv
- given vectornormal
- unit normal of the planepublic static boolean circleThruPoints(PdVector center, double radius, PdVector p, PdVector q, PdVector r)
dist = ||/|dir1xdir2|
.
Method works in euclidean vector spaces of arbitrary dimension.
center
- resulting center of circleradius
- resulting radius of circlep
- given pointq
- given pointr
- given pointtrue
if circle could be computed.public static boolean evalCircle(PdVector p, PdVector mid, PdVector orient, PdVector start, PdVector end, double t)
Method only works in euclidean 3-space.
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 segmenttrue
if circle could be evaluated.PdVector.angleWithOrientation(PdVector, PdVector, PdVector)
,
rotatePointAroundLine(PdVector, PdVector, PdVector, PdVector, double)
public static boolean evalHelix(PdVector p, PdVector axisBot, PdVector axisDir, PdVector start, PdVector end, double t)
Method only works in euclidean 3-space.
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 segmenttrue
if helix could be evaluated.PdVector.angleWithOrientation(PdVector, PdVector, PdVector)
,
rotatePointAroundLine(PdVector, PdVector, PdVector, PdVector, double)
public static boolean rotatePointAroundVector(PdVector pRot, PdVector p, PdVector axisDir, double alpha)
Method only works in euclidean 3-space.
pRot
- rotated pointp
- point to rotate. May be equal to pRot.axisDir
- unit direction of rotation axis through originalpha
- rotation angle, in radianstrue
if rotation could be performed.rotatePointAroundLine(PdVector,PdVector,PdVector,PdVector,double)
public static boolean rotatePointAroundLine(PdVector pRot, PdVector p, PdVector axisBase, PdVector axisDir, double alpha)
Method only works in euclidean 3-space.
pRot
- rotated pointp
- point to rotateaxisBase
- some point on the rotation axisaxisDir
- unit direction of rotation axisalpha
- rotation angletrue
if rotation could be performed.rotatePointAroundVector(PdVector,PdVector,PdVector,double)
public static double ctg(PdVector p, PdVector q1, PdVector q2)
Method works in Euclidean vector spaces of arbitrary dimension.
p
- vertex where to compute the cotangentq1
- other vertex of the triangleq2
- other vertex of the trianglectg(double[],PdVector,PdVector,PdVector)
public static void ctg(double[] ctg, PdVector p, PdVector q, PdVector r)
Method works in Euclidean vector spaces of arbitrary dimension.
ctg
- cotangent of all vertex anglesp
- vertex of the triangleq
- vertex of the triangler
- vertex of the trianglectg(PdVector,PdVector,PdVector)
,
PuMath.ctg(double[],double,double,double)
public static double sphericalAngle(PdVector p, PdVector q1, PdVector q2)
Method works in euclidean vector spaces of arbitrary dimension.
p
- vertex where to compute the angleq1
- other vertex of the triangleq2
- other vertex of the trianglePdVector.angle(PdVector,PdVector,PdVector)
public static double sphericalArea(PdVector p, PdVector q, PdVector r)
Method works in euclidean vector spaces of arbitrary dimension.
p
- vertex of the triangleq
- vertex of the triangler
- vertex of the trianglesphericalAngle(PdVector,PdVector,PdVector)
public static double[] frameToStandardFrame(PdVector first, PdVector second, PdVector third)
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.
first
- First vector of frame -> x-axis. FRAME MUST BE ORTHONORMAL!
Orthonormality is not checked by this method!second
- Second vector of frame -> y-axis. See first.third
- Third vector of frame -> z-axis. See first."