Documentation of 'jv.vecmath.PuVectorGeom' Java class
PuVectorGeom ("JavaView Reference Manual")
"JavaView? v5.03.003"
jv.vecmath

Class PuVectorGeom



  • public class PuVectorGeom
    extends java.lang.Object
    Static 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 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
         
           <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)
         
        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.
        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 for s by solving <n, b1+sd> = <n,b2> leading to s = <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 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.
        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:
         
           <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)
         
        Method only works in Euclidean 3-space.
        Parameters:
        lineBase - computed point on the intersection line
        lineDir - computed direction of the intersection line
        base1 - base point of plane1
        base2 - base point of plane2
        normal1 - unit normal of plane1
        normal2 - unit normal of plane2
        Returns:
        true if both planes intersect
        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 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.
        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 formula dist = <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 point
        base - some point of the line
        normal - 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 formula dist = |<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 line1
        base2 - base point of line2
        dir1 - direction of line1
        dir2 - 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 formula proj = 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 line
        p - given point
        base - some point of the line
        dir - 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 formula p - <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 plane
        p - given point
        base - some point of the plane
        normal - 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
        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
        mid - some point of the plane
        normal - 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 formula v = <v,dir>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
        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 formula vProj = <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 origin
        v - given vector
        dir - 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 formula v = v-<v,normal>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
        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 formula vProj = 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 origin
        v - given vector
        normal - 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 formula dist = |<base1-base2, dir1xdir2>|/|dir1xdir2|.

        Method works in Euclidean vector spaces of arbitrary dimension.

        Parameters:
        center - resulting center of circle
        radius - resulting radius of circle
        p - given point
        q - given point
        r - given point
        Returns:
        true if 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 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)
        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 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)
        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 point
        p - point to rotate. May be equal to pRot.
        axisDir - unit direction of rotation axis through origin
        alpha - rotation angle, in radians
        Returns:
        true if 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 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)
        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 cotangent
        q1 - other vertex of the triangle
        q2 - 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 angles
        p - vertex of the triangle
        q - vertex of the triangle
        r - 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 angle
        q1 - other vertex of the triangle
        q2 - 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 triangle
        q - vertex of the triangle
        r - 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)
"JavaView? v5.03.003"

"

The software JavaView? is copyright protected. All Rights Reserved.
"

Ads help maintain this website.