Package teilchen.util

Class Intersection

  • All Implemented Interfaces:
    java.io.Serializable

    public final class Intersection
    extends java.lang.Object
    implements java.io.Serializable
    beware this is not really in good shape. i ll read my linear algebra book and fix this class. someday. hopefully.
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int COINCIDENT
      from paul bourke ( http://local.wasp.uwa.edu.au/~pbourke/geometry/lineline2d/ )
      static int INTERSECTING  
      static int NOT_INTERSECTING  
      static int PARALLEL  
    • Constructor Summary

      Constructors 
      Constructor Description
      Intersection()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static float intersectLinePlane​(Ray3f pRay, Plane3f pPlane, processing.core.PVector pIntersectionPoint)
      intersect line with plane ( grabbed from Xith )
      static boolean intersectRayPlane​(Ray3f pRay, Plane3f pPlane, processing.core.PVector pResult, boolean doPlanar, boolean quad)  
      static processing.core.PVector[] intersectRaySpherePoints​(processing.core.PVector pSphereCenter, float pSphereRadius, processing.core.PVector pRayDirection, processing.core.PVector pRayOrigin)  
      static boolean intersectRayTriangle​(processing.core.PVector pRayOrigin, processing.core.PVector pRayDirection, processing.core.PVector v0, processing.core.PVector v1, processing.core.PVector v2, processing.core.PVector pIntersectionPoint)  
      static boolean intersectRayTriangle​(processing.core.PVector pRayOrigin, processing.core.PVector pRayDirection, processing.core.PVector v0, processing.core.PVector v1, processing.core.PVector v2, Intersection.IntersectionResult pResult, boolean pCullingFlag)
      Fast, Minimum Storage Ray-Triangle Intersection by Tomas Moeller & Ben Trumbore http://jgt.akpeters.com/papers/MollerTrumbore97/code.html
      static int lineLineIntersect​(processing.core.PVector aBegin, processing.core.PVector aEnd, processing.core.PVector bBegin, processing.core.PVector bEnd, processing.core.PVector pIntersection)  
      static boolean lineLineIntersect​(processing.core.PVector pP1, processing.core.PVector pP2, processing.core.PVector pP3, processing.core.PVector pP4, processing.core.PVector pPa, processing.core.PVector pPb)
      from paul bourke ( http://local.wasp.uwa.edu.au/~pbourke/geometry/lineline3d/ )
      static boolean RaySphere​(processing.core.PVector pP1, processing.core.PVector pP2, processing.core.PVector pSphereCenter, float pSphereRadius)
      http://local.wasp.uwa.edu.au/~pbourke/geometry/sphereline/raysphere.c Calculate the intersection of a ray and a sphere The line segment is defined from p1 to p2 The sphere is of radius r and centered at sc There are potentially two points of intersection given by p = p1 + mu1 (p2 - p1) p = p1 + mu2 (p2 - p1) Return FALSE if the ray doesn't intersect the sphere.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Intersection

        public Intersection()
    • Method Detail

      • intersectRayPlane

        public static boolean intersectRayPlane​(Ray3f pRay,
                                                Plane3f pPlane,
                                                processing.core.PVector pResult,
                                                boolean doPlanar,
                                                boolean quad)
      • intersectRayTriangle

        public static boolean intersectRayTriangle​(processing.core.PVector pRayOrigin,
                                                   processing.core.PVector pRayDirection,
                                                   processing.core.PVector v0,
                                                   processing.core.PVector v1,
                                                   processing.core.PVector v2,
                                                   processing.core.PVector pIntersectionPoint)
      • intersectLinePlane

        public static float intersectLinePlane​(Ray3f pRay,
                                               Plane3f pPlane,
                                               processing.core.PVector pIntersectionPoint)
        intersect line with plane ( grabbed from Xith )
        Parameters:
        pPlane - Plane3f
        pRay - Ray3f
        pIntersectionPoint - PVector
        Returns:
        float
      • intersectRayTriangle

        public static boolean intersectRayTriangle​(processing.core.PVector pRayOrigin,
                                                   processing.core.PVector pRayDirection,
                                                   processing.core.PVector v0,
                                                   processing.core.PVector v1,
                                                   processing.core.PVector v2,
                                                   Intersection.IntersectionResult pResult,
                                                   boolean pCullingFlag)
        Fast, Minimum Storage Ray-Triangle Intersection by Tomas Moeller & Ben Trumbore http://jgt.akpeters.com/papers/MollerTrumbore97/code.html
        Parameters:
        pRayOrigin - ray origin
        pRayDirection - ray direction
        v0 - triangle v0
        v1 - triangle v1
        v2 - triangle v2
        pResult - interesction result container
        pCullingFlag - culling
        Returns:
        returns true if intersections exists
      • RaySphere

        public static boolean RaySphere​(processing.core.PVector pP1,
                                        processing.core.PVector pP2,
                                        processing.core.PVector pSphereCenter,
                                        float pSphereRadius)
        http://local.wasp.uwa.edu.au/~pbourke/geometry/sphereline/raysphere.c Calculate the intersection of a ray and a sphere The line segment is defined from p1 to p2 The sphere is of radius r and centered at sc There are potentially two points of intersection given by p = p1 + mu1 (p2 - p1) p = p1 + mu2 (p2 - p1) Return FALSE if the ray doesn't intersect the sphere.
        Parameters:
        pP1 - P1
        pP2 - P2
        pSphereCenter - sphere center
        pSphereRadius - sphere radius
        Returns:
        returns true if intersection exists
      • lineLineIntersect

        public static int lineLineIntersect​(processing.core.PVector aBegin,
                                            processing.core.PVector aEnd,
                                            processing.core.PVector bBegin,
                                            processing.core.PVector bEnd,
                                            processing.core.PVector pIntersection)
      • lineLineIntersect

        public static boolean lineLineIntersect​(processing.core.PVector pP1,
                                                processing.core.PVector pP2,
                                                processing.core.PVector pP3,
                                                processing.core.PVector pP4,
                                                processing.core.PVector pPa,
                                                processing.core.PVector pPb)
        from paul bourke ( http://local.wasp.uwa.edu.au/~pbourke/geometry/lineline3d/ )

        Calculate the line segment PaPb that is the shortest route between two lines P1P2 and P3P4. Calculate also the values of mua and mub where Pa = P1 + mua (P2 - P1) Pb = P3 + mub (P4 - P3) Return FALSE if no solution exists.

        Parameters:
        pP1 - P1
        pP2 - P2
        pP3 - P3
        pP4 - P4
        pPa - Pa
        pPb - Pb
        Returns:
        sucess if solution exists
      • intersectRaySpherePoints

        public static processing.core.PVector[] intersectRaySpherePoints​(processing.core.PVector pSphereCenter,
                                                                         float pSphereRadius,
                                                                         processing.core.PVector pRayDirection,
                                                                         processing.core.PVector pRayOrigin)