Esempio n. 1
0
            /// <summary>
            ///
            /// </summary>
            private static Orient3d GetHalfedgeTransform(E hedge, Func <V, Vector3d> getPosition, double unrollFactor)
            {
                if (unrollFactor < 0.0)
                {
                    return(Orient3d.Identity);
                }

                var he0 = hedge;
                var he1 = he0.Twin;

                Vector3d p0 = getPosition(he0.Start);
                Vector3d p1 = getPosition(he1.Start);

                Vector3d p2 = (getPosition(he0.Previous.Start) + getPosition(he0.Next.End)) * 0.5;
                Vector3d p3 = (getPosition(he1.Previous.Start) + getPosition(he1.Next.End)) * 0.5;

                Vector3d x  = p1 - p0;
                Vector3d y0 = p2 - p0;
                Vector3d y1 = (unrollFactor < 1.0) ? y0.SlerpTo(p1 - p3, unrollFactor) : p1 - p3; // TODO handle anti-parallel case

                var t0 = new Orient3d(OrthoBasis3d.CreateFromXY(x, y0), p0);
                var t1 = new Orient3d(OrthoBasis3d.CreateFromXY(x, y1), p0);

                return(Orient3d.CreateFromTo(ref t0, ref t1));
            }
Esempio n. 2
0
            /// <summary>
            ///
            /// </summary>
            private static Orient3d GetHalfedgeTransform(E hedge, Func <V, Vec3d> getPosition, Func <E, double> getUnrollFactor = null)
            {
                if (getUnrollFactor == null)
                {
                    return(GetHalfedgeTransform(hedge, getPosition));
                }

                var t = getUnrollFactor(hedge);

                if (t < 0.0)
                {
                    return(Orient3d.Identity);
                }

                var he0 = hedge;
                var he1 = he0.Twin;

                Vec3d p0 = getPosition(he0.Start);
                Vec3d p1 = getPosition(he1.Start);

                Vec3d p2 = (getPosition(he0.Previous.Start) + getPosition(he0.Next.End)) * 0.5;
                Vec3d p3 = (getPosition(he1.Previous.Start) + getPosition(he1.Next.End)) * 0.5;

                Vec3d x  = p1 - p0;
                Vec3d y0 = p2 - p0;
                Vec3d y1 = (t < 1.0) ? y0.SlerpTo(p1 - p3, t) : p1 - p3; // TODO handle anti-parallel case

                return(Orient3d.CreateFromTo(
                           new Orient3d(p0, x, y0),
                           new Orient3d(p0, x, y1)
                           ));
            }
Esempio n. 3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="orient"></param>
 /// <returns></returns>
 public static Plane ToPlane(this Orient3d orient)
 {
     return(new Plane(
                orient.Translation,
                orient.Rotation.X,
                (Vector3d)orient.Rotation.Y
                ));
 }
Esempio n. 4
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="orient"></param>
 /// <returns></returns>
 public static Plane ToPlane(this Orient3d orient)
 {
     return(new Plane(
                orient.Translation.ToPoint3d(),
                orient.Rotation.X.ToVector3d(),
                orient.Rotation.Y.ToVector3d()
                ));
 }
 /// <summary>
 ///
 /// </summary>
 /// <typeparam name="V"></typeparam>
 /// <typeparam name="E"></typeparam>
 /// <typeparam name="F"></typeparam>
 /// <returns></returns>
 public static Orient3d GetFrame <V, E, F>(this HeStructure <V, E, F> .Halfedge hedge, Func <V, Vector3d> getPosition)
     where V : HeStructure <V, E, F> .Vertex
     where E : HeStructure <V, E, F> .Halfedge
     where F : HeStructure <V, E, F> .Face
 {
     return(Orient3d.CreateFromPoints(
                getPosition(hedge.Start),
                getPosition(hedge.Next.Start),
                getPosition(hedge.Previous.Start)
                ));
 }
Esempio n. 6
0
 /// <summary>
 ///
 /// </summary>
 /// <typeparam name="V"></typeparam>
 /// <typeparam name="E"></typeparam>
 /// <typeparam name="F"></typeparam>
 /// <returns></returns>
 public static Orient3d GetFrame <V, E, F>(this Halfedge <V, E, F> hedge, Func <V, Vec3d> getPosition)
     where V : HeVertex <V, E, F>
     where E : Halfedge <V, E, F>
     where F : HeFace <V, E, F>
 {
     return(Orient3d.CreateFromPoints(
                getPosition(hedge.Start),
                getPosition(hedge.Next.Start),
                getPosition(hedge.Previous.Start)
                ));
 }
Esempio n. 7
0
            /// <summary>
            ///
            /// </summary>
            private static Orient3d GetHalfedgeTransform(E hedge, Func <V, Vector3d> getPosition)
            {
                var he0 = hedge;
                var he1 = he0.Twin;

                Vector3d p0 = getPosition(he0.Start);
                Vector3d p1 = getPosition(he1.Start);

                Vector3d p2 = (getPosition(he0.Previous.Start) + getPosition(he0.Next.End)) * 0.5;
                Vector3d p3 = (getPosition(he1.Previous.Start) + getPosition(he1.Next.End)) * 0.5;

                Vector3d x  = p1 - p0;
                var      t0 = new Orient3d(OrthoBasis3d.CreateFromXY(x, p2 - p0), p0);
                var      t1 = new Orient3d(OrthoBasis3d.CreateFromXY(x, p1 - p3), p0);

                return(Orient3d.CreateFromTo(ref t0, ref t1));
            }
Esempio n. 8
0
            /// <summary>
            ///
            /// </summary>
            private static Orient3d GetHalfedgeTransform(E hedge, Func <V, Vec3d> getPosition)
            {
                var he0 = hedge;
                var he1 = he0.Twin;

                Vec3d p0 = getPosition(he0.Start);
                Vec3d p1 = getPosition(he1.Start);

                Vec3d p2 = (getPosition(he0.Previous.Start) + getPosition(he0.Next.End)) * 0.5;
                Vec3d p3 = (getPosition(he1.Previous.Start) + getPosition(he1.Next.End)) * 0.5;

                Vec3d x = p1 - p0;

                return(Orient3d.CreateFromTo(
                           new Orient3d(p0, x, p2 - p0),
                           new Orient3d(p0, x, p1 - p3)
                           ));
            }