コード例 #1
0
        public static bool Cross(TriangleF t1, TriangleF t2, out double Lam, out double Mue, out xyz P, out xyz Q)
        {
            xyzArray A = new xyzArray();
            xyzArray B = new xyzArray();

            A.data = new xyz[] { t1.A.Toxyz(), t1.B.Toxyz(), t1.C.Toxyz() };
            B.data = new xyz[] { t2.A.Toxyz(), t2.B.Toxyz(), t2.C.Toxyz() };
            Lam    = -1;
            Mue    = -1;
            P      = new Drawing3d.xyz(0, 0, 0);
            Q      = new Drawing3d.xyz(0, 0, 0);

            double d = (A.Distance(B, 1e10, out Lam, out Mue));

            if (d < 2)
            {
                P = A.Value(Lam);
                Q = B.Value(Mue);
                return(true);
            }
            return(false);
        }
コード例 #2
0
ファイル: Bezier3d.cs プロジェクト: unitycoder/Drawing3D
 /// <summary>
 /// Overrides the <see cref="Curve3D.setBtang"/> by setting Points[2] to Points[3] - value;
 /// </summary>
 /// <param name="value">Endtangent</param>
 protected override void setBtang(xyz value)
 {
     Points[2] = Points[3] - value;
 }
コード例 #3
0
ファイル: Bezier3d.cs プロジェクト: unitycoder/Drawing3D
 /// <summary>
 /// Overrides the <see cref="Curve3D.setAtang"/>-method
 /// </summary>
 /// <param name="value">Starttangent</param>
 protected override void setAtang(xyz value)
 {
     Points[1] = Points[0] + value;
 }
コード例 #4
0
        void RefreshNormals()
        {
            Normals          = new Loxyz();
            Normals.Count    = Bounds.Count;
            DrawPoints       = new Loxyz();
            DrawPoints.Count = ParamCurves.Count;
            if (!DrawRelativToSurfaceBase)
            {
                for (int i = 0; i < Bounds.Count; i++)
                {
                    EdgeLoop EL = Bounds[i];
                    for (int k = 0; k < EL.Count; k++)
                    {
                        Edge E = EL[k];
                        DrawPoints[i].Add(E.EdgeStart.Value);
                    }
                }
            }

            for (int i = 0; i < ParamCurves.Count; i++)
            {
                xyArray A = ParamCurves[i].getxyArrayClosed(false);
                if (DrawRelativToSurfaceBase)
                {
                    DrawPoints[i] = A.ToxyzArray();
                }

                int ct = 0;
                for (int t = 0; t < ParamCurves[i].Count; t++)
                {
                    ct = ct + ParamCurves[i][t].Resolution;
                }
                xyzArray NormalsLoop = new xyzArray(ct);
                Normals[i] = NormalsLoop;
                int id = 0;

                for (int j = 0; j < ParamCurves[i].Count; j++)
                {
                    List <Face> L = GetFaces(this, i, j);
                    Edge        E = Bounds[i][j];

                    if (L == null)
                    {
                        Normals = null;

                        DrawPoints = null;
                        return;
                    }
                    double SmoothAngle = Parent.SmoothAngle;
                    xyz    N           = Surface.Normal(0, 0).normalized();
                    xyz    N1          = Surface.Normal(0, 0).normalized();
                    for (int k = 0; k < L.Count; k++)
                    {
                        if (System.Math.Abs((N1 * L[k].Surface.Normal(0, 0).normalized())) > System.Math.Cos(SmoothAngle))
                        {
                            N = N + L[k].Surface.Normal(0, 0).normalized();
                        }
                    }
                    N = N.normalized();
                    if (DrawRelativToSurfaceBase)
                    {
                        Matrix M = Surface.Base.ToMatrix().invert();
                        N = M * N - M * new xyz(0, 0, 0);
                    }

                    NormalsLoop[id] = N;
                    id++;
                }
            }
        }
コード例 #5
0
        /// <summary>
        /// creates a <see cref="Face"/> for a <see cref="Solid"/> in the <see cref="Model.Solid"/>.
        /// The Curves are all <see cref="Line3D"/>. The <see cref="Face"/> is plane and has as <see cref="Face.Surface"/> a <see cref="PlaneSurface"/>.
        /// </summary>
        /// <param name="Solid">is the target in which the <see cref="Face"/> will be posed.</param>
        /// <param name="Bounds">contains the <see cref="Vertex3d"/> for the <see cref="Line3D"/>.</param>
        /// <returns>a <see cref="Face"/></returns>
        public static Face SolidPlane(Solid Solid, Vertex3dArray_2 Bounds)
        {
            if (Bounds.Count == 0)
            {
                return(null);
            }
            xyz N = new xyz(0, 0, 0);
            xyz P = Bounds[0][0].Value;

            for (int i = 1; i < Bounds[0].Count - 1; i++)
            {
                xyz A = Bounds[0][i].Value;
                xyz B = Bounds[0][i + 1].Value;
                xyz M = N;
                N = N + ((A - P) & (B - P));
            }
            N = N.normalized() * (-1);
            Base Base = Base.UnitBase;

            Base.BaseO = P;
            Base.BaseZ = N;
            if ((Base.BaseZ & new xyz(1, 0, 0)).dist(xyz.Null) > 0.01)
            {
                Base.BaseY = (Base.BaseZ & (new xyz(1, 0, 0))).normalized();
                Base.BaseX = Base.BaseY & Base.BaseZ;
            }
            else
            {
                Base.BaseY = (Base.BaseZ & (new xyz(0, 1, 0))).normalized();
                Base.BaseX = Base.BaseY & Base.BaseZ;
            }

            PlaneSurface Surface = new PlaneSurface();

            Surface.Base = Base;
            //-------------------------------------
            //-------- Create the Face
            Face Result = new Face();

            // ---- With Plane Surface
            Result.Surface = Surface;
            if (Solid != null)
            {
                Solid.FaceList.Add(Result);
            }
            //----- Set the Edges
            for (int i = 0; i < Bounds.Count; i++)
            {
                EdgeLoop Edgeloop = new EdgeLoop();
                Result.Bounds.Add(Edgeloop);
                for (int j = 0; j < Bounds[i].Count; j++)
                {
                    Vertex3d A = Bounds[i][j];
                    Vertex3d B = null;
                    if (j == Bounds[i].Count - 1)
                    {
                        B = Bounds[i][0];
                    }
                    else
                    {
                        B = Bounds[i][j + 1];
                    }
                    Edge E = Edge.SolidEdge(Solid, Result, A, B, new Line3D(A.Value, B.Value));

                    Edgeloop.Add(E);
                }
            }

            Result.RefreshParamCurves();
            return(Result);
        }
コード例 #6
0
ファイル: xyzArray.cs プロジェクト: unitycoder/Drawing3D
 public bool ClockWise(xyz Direction)
 {
     return(cross() * Direction < 0);
 }