public static Ray Transform(Ray ray, Matrix4X4 matrix) { Vector3 transformedOrigin = Vector3Ex.TransformPosition(ray.origin, matrix); Vector3 transformedDirecton = Vector3Ex.TransformVector(ray.directionNormal, matrix); return(new Ray(transformedOrigin, transformedDirecton, ray.minDistanceToConsider, ray.maxDistanceToConsider, ray.intersectionType)); }
public static Plane Transform(Plane inputPlane, Matrix4X4 matrix) { Vector3 planeNormal = inputPlane.Normal; double distanceToPlane = inputPlane.DistanceFromOrigin; Plane outputPlane = new Plane(); outputPlane.Normal = Vector3Ex.TransformVector(planeNormal, matrix).GetNormal(); Vector3 pointOnPlane = planeNormal * distanceToPlane; Vector3 pointOnTransformedPlane = Vector3Ex.Transform(pointOnPlane, matrix); outputPlane.DistanceFromOrigin = Vector3Ex.Dot(outputPlane.Normal, pointOnTransformedPlane); return(outputPlane); }