public void ProjectUnprojectTest() { var normal = new V3d(-3.38012399699281E-17, -0.000407306344606881, -0.999999917050768); var distance = -13.109839358218661; var plane = new Plane3d(normal, distance); var testPoint = new V3d(-97.076092093139, -148.399088699813, 13.170284341045); // NOTE: Rot3d in Euclidean3d has numerical issue var projectedPoint = plane.ProjectToPlaneSpace(testPoint); var unprojectedPoint = plane.Unproject(projectedPoint); var planeTrafo = Trafo3d.FromNormalFrame(plane.Point, plane.Normal); var projectedPoint2 = planeTrafo.Backward.TransformPos(testPoint).Func(x => x.XY); var unprojectedPoint2 = planeTrafo.Forward.TransformPos(projectedPoint2.Func(x => x.XYO)); Requires.That((unprojectedPoint - unprojectedPoint2).Length < 0.01); }
/// <summary> /// Returns a transformation of an orthonormal basis in Plane- to WorldSpace. /// </summary> public static Trafo3d GetPlaneSpaceTransform(this Plane3d self) => Trafo3d.FromNormalFrame(self.Point, self.Normal);