Exemple #1
0
        internal Vector3d CalcConjugateNormal()
        {
            var nm = tring1.GetPlane().Normal.Normalized();

            var          point0 = AuxPoint0;
            var          point1 = AuxPoint1;
            var          neg    = -nm;
            var          axis   = (edge.End - edge.Start).Normalized();
            PlaneSurface pp     = new PlaneSurface()
            {
                Position = edge.Start, Normal = axis
            };
            var prj0 = pp.ProjPoint(point0) - edge.Start;
            var prj1 = pp.ProjPoint(point1) - edge.Start;

            var crs1 = Vector3d.Cross(prj0, prj1) / prj0.Length / prj1.Length;
            var ang2 = Vector3d.CalculateAngle(prj0, prj1);

            if (crs1.Length > 1e-8)
            {
                axis = -crs1.Normalized();
            }
            var mtr    = Matrix4d.CreateFromAxisAngle(axis, ang2);
            var mtr2   = Matrix4d.CreateFromAxisAngle(axis, -ang2);
            var trans  = Vector3d.Transform(neg, mtr2);
            var check  = Vector3d.Transform(prj0.Normalized(), mtr);
            var check2 = Vector3d.Transform(prj1.Normalized(), mtr);

            if (!(Vector3d.Cross(tring2.GetPlane().Normal, trans).Length < 1e-8 || Vector3d.Cross(tring2.GetPlane().Normal, -trans).Length < 1e-8))
            {
                DebugHelper.Error?.Invoke("inconsistent normal was calculated");
            }

            normal1 = trans;
            return(trans);
        }