Example #1
0
 public static void InersectPlane(ref Line3 line, ref Vector3 planeNormal, ref Vector3 planeLocation, out Vector3 result)
 {
     float dot = (-(planeNormal.X*planeLocation.X) - (planeNormal.Y*planeLocation.Y) - (planeNormal.Z*planeLocation.Z));
     float dot3 = (planeNormal.X*(line.Point2.X-line.Point1.X)) + (planeNormal.Y*(line.Point2.Y-line.Point1.Y)) + (planeNormal.Z*(line.Point2.Z-line.Point1.Z));
     float dot2 = -((dot + (planeNormal.X*line.Point1.X) + (planeNormal.Y*line.Point1.Y) + (planeNormal.Z*line.Point1.Z)) / dot3);
     result = (line.Point1 + (dot2*(line.Point2-line.Point1)));
 }
Example #2
0
 //public bool InersectTriangle(out Vector3f pInersectPoint, Vector3f pPolygonPoint1, Vector3f pPolygonPoint2, Vector3f pPolygonPoint3, Vector3f pPolygonNormal, Bound3D pPolygonBoundingBox, Line3f pLine)
 //{
 //    pInersectPoint = Inersect(pPolygonNormal, pPolygonPoint1, pLine);
 //    if (pInersectPoint.WithinTriangle(pPolygonBoundingBox) == false) return false;
 //    return Within(pPolygonPoint1, pPolygonPoint2, pPolygonPoint3);
 //}
 public Line3 Inersect(Line3 line)
 {
     Vector3 vector = (Point1 - line.Point1), vector2 = (line.Point2 - line.Point1), vector3 = (Point2 - Point1);
        float dot1 = vector.Dot(vector2);
        float dot2 = vector2.Dot(vector3);
        float dot3 = vector.Dot(vector3);
        float dot4 = vector2.Dot();
        float dot5 = vector3.Dot();
        float mul1 = (((dot1 * dot2) - (dot3 * dot4)) / ((dot5 * dot4) - (dot2 * dot2)));
        float mul2 = (dot1 + (dot2 * mul1)) / dot4;
        return new Line3((Point1 + (mul1 * vector3)), (line.Point1 + (mul2 * vector2)));
 }
Example #3
0
 public static void Inersect(ref Line3 line1, ref Line3 line2, out Line3 result)
 {
     Vector3 vector = (line1.Point1 - line2.Point1), vector2 = (line2.Point2 - line2.Point1), vector3 = (line1.Point2 - line1.Point1);
        float dot1 = vector.Dot(vector2);
        float dot2 = vector2.Dot(vector3);
        float dot3 = vector.Dot(vector3);
        float dot4 = vector2.Dot();
        float dot5 = vector3.Dot();
        float mul1 = (((dot1 * dot2) - (dot3 * dot4)) / ((dot5 * dot4) - (dot2 * dot2)));
        float mul2 = (dot1 + (dot2 * mul1)) / dot4;
        result = new Line3((line1.Point1 + (mul1 * vector3)), (line2.Point1 + (mul2 * vector2)));
 }
Example #4
0
 public static void Transform(ref Line3 line, ref Matrix3 matrix, out Line3 result)
 {
     Vector3.Transform(ref line.Point1, ref matrix, out result.Point1);
     Vector3.Transform(ref line.Point2, ref matrix, out result.Point2);
 }
Example #5
0
 public static void Length(ref Line3 line, out float result)
 {
     result = (line.Point1 - line.Point2).Length();
 }
Example #6
0
 public Vector3 InersectLine(Line3 line)
 {
     Vector3 pointOffset = (this-line.Point1), vector = (line.Point2-line.Point1).Normalize();
     return (vector * pointOffset.Dot(vector)) + line.Point1;
 }
Example #7
0
 public static void InersectLine(ref Vector3 vector, ref Line3 line, out Vector3 result)
 {
     Vector3 pointOffset = (vector-line.Point1), vec = (line.Point2-line.Point1).Normalize();
     result = (vec * pointOffset.Dot(vec)) + line.Point1;
 }
Example #8
0
 public void Rotate(Line3 pLine, float radians)
 {
     var vector = (pLine.Point2 - pLine.Point1).NormalizeSafe();
     Position -= pLine.Point1;
     LookAtPosition -= pLine.Point1;
     UpPosition -= pLine.Point1;
     Position = Position.RotateAround(vector, radians);
     LookAtPosition = LookAtPosition.RotateAround(vector, radians);
     UpPosition = UpPosition.RotateAround(vector, radians);
     Position += pLine.Point1;
     LookAtPosition += pLine.Point1;
     UpPosition += pLine.Point1;
 }
Example #9
0
        public static void InersectLine(ref Vector3 vector, ref Line3 line, out Vector3 result)
        {
            Vector3 pointOffset = (vector - line.Point1), vec = (line.Point2 - line.Point1).Normalize();

            result = (vec * pointOffset.Dot(vec)) + line.Point1;
        }
Example #10
0
        public Vector3 InersectLine(Line3 line)
        {
            Vector3 pointOffset = (this - line.Point1), vector = (line.Point2 - line.Point1).Normalize();

            return((vector * pointOffset.Dot(vector)) + line.Point1);
        }