Beispiel #1
0
 public static double PlaneAngleD(Vector3d a, Vector3d b, int nPlaneNormalIdx = 1)
 {
     a[nPlaneNormalIdx] = b[nPlaneNormalIdx] = 0.0;
     a.Normalize();
     b.Normalize();
     return(Vector3d.AngleD(a, b));
 }
Beispiel #2
0
        public static double PlaneAngleSignedD(Vector3d vFrom, Vector3d vTo, int nPlaneNormalIdx = 1)
        {
            vFrom[nPlaneNormalIdx] = vTo[nPlaneNormalIdx] = 0.0;
            vFrom.Normalize();
            vTo.Normalize();
            double fSign  = Math.Sign(vFrom.Cross(vTo)[nPlaneNormalIdx]);
            double fAngle = fSign * Vector3d.AngleD(vFrom, vTo);

            return(fAngle);
        }
Beispiel #3
0
        public static double PlaneAngleSignedD(Vector3d vFrom, Vector3d vTo, Vector3d planeN)
        {
            vFrom = vFrom - Vector3d.Dot(vFrom, planeN) * planeN;
            vTo   = vTo - Vector3d.Dot(vTo, planeN) * planeN;
            vFrom.Normalize();
            vTo.Normalize();
            Vector3d c      = Vector3d.Cross(vFrom, vTo);
            double   fSign  = Math.Sign(Vector3d.Dot(c, planeN));
            double   fAngle = fSign * Vector3d.AngleD(vFrom, vTo);

            return(fAngle);
        }
        public static double OpeningAngleD(DMesh3 mesh, int eid)
        {
            Index2i et = mesh.GetEdgeT(eid);

            if (et[1] == DMesh3.InvalidID)
            {
                return(double.MaxValue);     // boundary edge!!
            }
            Vector3d n0 = mesh.GetTriNormal(et[0]);
            Vector3d n1 = mesh.GetTriNormal(et[1]);

            return(Vector3d.AngleD(n0, n1));
        }
Beispiel #5
0
        public static double PlaneAngleSignedD(Vector3d vFrom, Vector3d vTo, int nPlaneNormalIdx = 1)
        {
            vFrom[nPlaneNormalIdx] = vTo[nPlaneNormalIdx] = 0.0;
            vFrom.Normalize();
            vTo.Normalize();
            Vector3d c = vFrom.Cross(vTo);

            if (c.LengthSquared < MathUtil.ZeroTolerance)
            {                    // vectors are parallel
                return(vFrom.Dot(vTo) < 0 ? 180.0 : 0);
            }
            double fSign  = Math.Sign(c[nPlaneNormalIdx]);
            double fAngle = fSign * Vector3d.AngleD(vFrom, vTo);

            return(fAngle);
        }
Beispiel #6
0
        public static double PlaneAngleSignedD(Vector3d vFrom, Vector3d vTo, Vector3d planeN)
        {
            vFrom = vFrom - Vector3d.Dot(vFrom, planeN) * planeN;
            vTo   = vTo - Vector3d.Dot(vTo, planeN) * planeN;
            vFrom.Normalize();
            vTo.Normalize();
            var c = Vector3d.Cross(vFrom, vTo);

            if (c.LengthSquared < MathUtil.ZeroTolerance)
            {                    // vectors are parallel
                return(vFrom.Dot(vTo) < 0 ? 180.0 : 0);
            }
            double fSign  = Math.Sign(Vector3d.Dot(c, planeN));
            double fAngle = fSign * Vector3d.AngleD(vFrom, vTo);

            return(fAngle);
        }
        /// <summary>
        /// Compute opening angle at vertex i in degrees
        /// </summary>
        public double OpeningAngleDeg(int i)
        {
            int prev = i - 1, next = i + 1;

            if (Closed)
            {
                int NV = vertices.Count;
                prev = (i == 0) ? NV - 1 : prev;
                next = next % NV;
            }
            else
            {
                if (i == 0 || i == vertices.Count - 1)
                {
                    return(180);
                }
            }
            Vector3d e1 = (vertices[prev] - vertices[i]);
            Vector3d e2 = (vertices[next] - vertices[i]);

            e1.Normalize(); e2.Normalize();
            return(Vector3d.AngleD(e1, e2));
        }