Beispiel #1
0
        /// <summary>
        /// implements the <see cref="INurbs3d.getUKnots"/> method.
        /// </summary>
        /// <returns></returns>

        public override xyz[,] getCtrlPoints()
        {
            double Factor = 0.0000;

            xyz[,] ControlPoints = new xyz[, ]  {
                { new xyz(0, Factor, -Radius), new xyz(0, Radius, -Radius), new xyz(0, Radius, 0), new xyz(0, Radius, Radius), new xyz(0, Factor, Radius) },
                { new xyz(-Factor, Factor, -Radius), new xyz(-Radius, Radius, -Radius), new xyz(-Radius, Radius, 0), new xyz(-Radius, Radius, Radius), new xyz(-Factor, Factor, Radius) },
                { new xyz(-Factor, 0, -Radius), new xyz(-Radius, 0, -Radius), new xyz(-Radius, 0, 0), new xyz(-Radius, 0, Radius), new xyz(-Factor, 0, Radius) },
                { new xyz(-Factor, -Factor, -Radius), new xyz(-Radius, -Radius, -Radius), new xyz(-Radius, -Radius, 0), new xyz(-Radius, -Radius, Radius), new xyz(-Factor, -Factor, Radius) },
                { new xyz(0, -Factor, -Radius), new xyz(0, -Radius, -Radius), new xyz(0, -Radius, 0), new xyz(0, -Radius, Radius), new xyz(0, -Factor, Radius) },
                { new xyz(Factor, -Factor, -Radius), new xyz(Radius, -Radius, -Radius), new xyz(Radius, -Radius, 0), new xyz(Radius, -Radius, Radius), new xyz(Factor, -Factor, Radius) },
                { new xyz(Factor, 0, -Radius), new xyz(Radius, 0, -Radius), new xyz(Radius, 0, 0), new xyz(Radius, 0, Radius), new xyz(Factor, 0, Radius) },
                { new xyz(Factor, Factor, -Radius), new xyz(Radius, Radius, -Radius), new xyz(Radius, Radius, 0), new xyz(Radius, Radius, Radius), new xyz(Factor, Factor, Radius) },
                { new xyz(0, Factor, -Radius), new xyz(0, Radius, -Radius), new xyz(0, Radius, 0), new xyz(0, Radius, Radius), new xyz(0, Factor, Radius) }
            };
            for (int i = 0; i < ControlPoints.GetLength(0); i++)
            {
                for (int j = 0; j < ControlPoints.GetLength(1); j++)
                {
                    ControlPoints[i, j] = Base.Absolut(ControlPoints[i, j]);
                }
            }

            return(ControlPoints);
        }
Beispiel #2
0
        /// <summary>
        /// implements the <see cref="INurbs3d.getUKnots"/> method.
        /// </summary>
        /// <returns></returns>
        public override xyz[,] getCtrlPoints()
        {
            RefreshEnvBox();
            double BaseRadius = Radius;
            double Max        = Env.Y + Env.Height;
            double Min        = Env.Y;

            xyz[,] CP = new xyz[, ]
            {
                { new xyz(BaseRadius, 0, 0), new xyz(BaseRadius, 0, Height) },
                { new xyz(BaseRadius, BaseRadius, 0), new xyz(BaseRadius, BaseRadius, Height) },
                { new xyz(0, BaseRadius, 0), new xyz(0, BaseRadius, Height) },
                { new xyz(-BaseRadius, BaseRadius, 0), new xyz(-BaseRadius, BaseRadius, Height) },
                { new xyz(-BaseRadius, 0, 0), new xyz(-BaseRadius, 0, Height) },
                { new xyz(-BaseRadius, -BaseRadius, 0), new xyz(-BaseRadius, -BaseRadius, Height) },
                { new xyz(0, -BaseRadius, 0), new xyz(0, -BaseRadius, Height) },
                { new xyz(BaseRadius, -BaseRadius, 0), new xyz(BaseRadius, -BaseRadius, Height) },
                { new xyz(BaseRadius, 0, 0), new xyz(BaseRadius, 0, Height) },
            };

            for (int i = 0; i < CP.GetLength(0); i++)
            {
                for (int j = 0; j < CP.GetLength(1); j++)
                {
                    CP[i, j] = Base.Absolut(CP[i, j]);
                }
            }
            return(CP);
        }
Beispiel #3
0
        /// <summary>
        /// Calculates the partial v derivation of the <see cref="BSplineSurface"/>.
        /// </summary>
        /// <param name="u">Parameter u.</param>
        /// <param name="v">Parameter v.</param>
        /// <returns>The partial v derivation.</returns>
        public override xyz vDerivation(double u, double v)
        {
            if ((UKnots == null) || (VKnots == null))
            {
                return(new xyz(0, 0, 0));
            }
            Utils.SplineExValue[] VCoeffs = Utils.CoeffSplineEx(VKnots, ControlPoints.GetLength(1), VDegree, VPeriodicity, v);
            double[] UCoeffs  = Utils.CoeffSpline(UKnots, ControlPoints.GetLength(0), UDegree, UPeriodicity, u);
            double   WDerived = 0;
            double   W        = 0;

            for (int i = 0; i < UCoeffs.Length; i++)
            {
                for (int j = 0; j < VCoeffs.Length; j++)
                {
                    W        = W + Weights[i, j] * UCoeffs[i] * VCoeffs[j].Value;
                    WDerived = WDerived + Weights[i, j] * UCoeffs[i] * VCoeffs[j].Derivation;
                }
            }


            xyz Result = new xyz();

            for (int i = 0; i < ControlPoints.GetLength(0); i++)
            {
                for (int k = 0; k < ControlPoints.GetLength(1); k++)
                {
                    Result = Result + ControlPoints[i, k] * (Weights[i, k] * UCoeffs[i] * (VCoeffs[k].Derivation * W - WDerived * VCoeffs[k].Value) / (W * W));
                }
            }
            return(Base.Absolut(Result) - Base.BaseO);
        }
Beispiel #4
0
        /// <summary>
        /// Calculates partial uderivation  of the <see cref="Torus"/>.
        /// </summary>
        /// <param name="u">Parameter u.</param>
        /// <param name="v">Parameter v.</param>
        /// <returns>The partial u-derivation for the torus.</returns>
        public override xyz uDerivation(double u, double v)
        {
            double x = -(InnerRadius * System.Math.Cos(v * VFactor) + OuterRadius) * System.Math.Sin(u * UFactor) * UFactor;
            double y = (InnerRadius * System.Math.Cos(v * VFactor) + OuterRadius) * System.Math.Cos(u * UFactor) * UFactor;
            double z = 0;

            return(Base.Absolut(new xyz(x, y, z)) - Base.BaseO);
        }
Beispiel #5
0
        /// <summary>
        /// Calculates the partial vDerivation
        /// </summary>
        /// <param name="u">first parameter</param>
        /// <param name="v">second parameter</param>
        /// <returns>value of the partial vDerivation</returns>

        public override xyz vDerivation(double u, double v)
        {
            double x = Radius * System.Math.Cos((u) * UFactor + 0.25 * System.Math.PI * 2) * System.Math.Cos(v * VFactor);
            double y = Radius * System.Math.Sin((u) * UFactor + 0.25 * System.Math.PI * 2) * System.Math.Cos(v * VFactor);
            double z = Radius * System.Math.Sin(v * VFactor);

            return(Base.Absolut(new xyz(x, y, z)) - Base.BaseO);
        }
Beispiel #6
0
        /// <summary>
        /// overrides <see cref="Surface.vDerivation(double, double)"/>.
        /// </summary>
        /// <param name="u">first parameter.</param>
        /// <param name="v">second parameter.</param>
        /// <returns>is the partial v deriavation.</returns>
        public override xyz vDerivation(double u, double v)
        {
            double x = -System.Math.Sin(v * Math.PI * 2 * (ToAngle / VFactor + (1 - v) * FromAngle / VFactor)) * Curve.Value(u).x;
            double y = System.Math.Cos(v * Math.PI * 2 * (ToAngle / VFactor + (1 - v) * FromAngle / VFactor)) * Curve.Value(u).x;
            double z = 0;
            xyz    Q = new xyz(x, y, z);

            return(Base.Absolut(Q) - Base.BaseO);
        }
Beispiel #7
0
        /// <summary>
        /// Calculates the circle in the center of the torus.
        /// </summary>
        /// <param name="u">Specifies a parameter in [0,1] for which a circle points will be calculated.</param>
        /// <returns>Returns a point on the center circle of the torus.</returns>
        public xyz CenterCircle(double u)
        {
            double x = OuterRadius * System.Math.Cos(u * UFactor);
            double y = OuterRadius * System.Math.Sin(u * UFactor);
            double z = 0;

            return(Base.Absolut(new xyz(x, y, z)));
            //  double dummy = x;
        }
Beispiel #8
0
        /// <summary>
        /// overrides the <see cref="Surface.uDerivation(double, double)"/>.
        /// </summary>
        /// <param name="u">first paramter.</param>
        /// <param name="v">second paramter.</param>
        /// <returns>is the partial u deriavation.</returns>
        public override xyz uDerivation(double u, double v)
        {
            xyz    CurveDerive = Curve.Derivation(u);
            double x           = System.Math.Cos(v * VFactor) * Curve.Derivation(u).x - Math.Sin(v * VFactor) * (Curve.Derivation(u).y);
            double y           = Math.Sin(v * VFactor) * Curve.Derivation(u).x + System.Math.Cos(v * VFactor) * (Curve.Derivation(u).y);
            double z           = Curve.Derivation(u).z;

            return(Base.Absolut(new xyz(x, y, z)) - Base.BaseO);
        }
Beispiel #9
0
        /// <summary>
        /// Calculates partial v-derivation  of the <see cref="Torus"/>.
        /// </summary>
        /// <param name="u">Parameter u.</param>
        /// <param name="v">Parameter v.</param>
        /// <returns>The partial v-derivation for the torus.</returns>
        public override xyz vDerivation(double u, double v)
        {
            double x = -InnerRadius *System.Math.Sin(v *VFactor) * VFactor * System.Math.Cos(u * UFactor);

            double y = -InnerRadius *System.Math.Sin(v *VFactor) * VFactor * System.Math.Sin(u * UFactor);

            double z = InnerRadius * System.Math.Cos(v * VFactor) * VFactor;

            return(Base.Absolut(new xyz(x, y, z)) - Base.BaseO);
        }
Beispiel #10
0
        /// <summary>
        /// overrides the <see cref="Surface.vDerivation(double, double)"/>.
        /// </summary>
        /// <param name="u">first paramter.</param>
        /// <param name="v">second paramter.</param>
        /// <returns>is the partial v deriavation.</returns>
        public override xyz vDerivation(double u, double v)
        {
            xyz    P = Curve.Value(u);
            double x = -System.Math.Sin(v * VFactor) * VFactor * Curve.Value(u).x - Math.Cos(v * VFactor) * VFactor * (Curve.Value(u).y);
            double y = Math.Cos(v * VFactor) * VFactor * Curve.Value(u).x - System.Math.Sin(v * VFactor) * VFactor * Curve.Value(u).y;
            double z = 0;
            xyz    Q = new xyz(x, y, z);

            return(Base.Absolut(Q) - Base.BaseO);
        }
Beispiel #11
0
 /// <summary>
 /// overrides the <see cref="Value(double, double)"/> method.
 /// </summary>
 /// <param name="u">the u parameter.</param>
 /// <param name="v">the v parameter.</param>
 /// <returns></returns>
 public override xyz Value(double u, double v)
 {
     if (ZHeight(u, v) != 0)
     {
         return(Base.Absolut(Utils.BezierSurfacePt(ControlPoints, u, v) + Normal(u, v) * ZHeight(u, v)));
     }
     else
     {
         return(Base.Absolut(Utils.BezierSurfacePt(ControlPoints, u, v)));
     }
 }
Beispiel #12
0
        /// <summary>
        /// Overrides the Value function and implements the Cylinder calulations.
        /// </summary>
        /// <param name="u">Specifies the u parameter int [0,1]</param>
        /// <param name="v">Specifies the v parameter int [0,1]</param>
        /// <returns>returns a xyz Point</returns>
        public override xyz Value(double u, double v)
        {
            double x = Radius * System.Math.Cos(u * UFactor);
            double y = Radius * System.Math.Sin(u * UFactor);
            double z = Height * v;

            if (ZHeight(u, v) > 0)
            {
                return(Base.Absolut(new xyz(x, y, z) + Normal(u, v) * ZHeight(u, v)));
            }

            return(Base.Absolut(new xyz(x, y, z)));
        }
Beispiel #13
0
        /// <summary>
        /// Calculates the value of the <see cref="Torus"/>.
        /// </summary>
        /// <param name="u">Parameter u.</param>
        /// <param name="v">Parameter v.</param>
        /// <returns>The Evaluation for the torus.</returns>
        public override xyz Value(double u, double v)
        {
            double IR = InnerRadius;
            double OR = OuterRadius;
            double x  = (IR * System.Math.Cos(v * VFactor) + OR) * System.Math.Cos(u * UFactor);
            double y  = (IR * System.Math.Cos(v * VFactor) + OR) * System.Math.Sin(u * UFactor);
            double z  = IR * System.Math.Sin(v * VFactor);

            if (ZHeight(u, v) > 0)
            {
                return(Base.Absolut(new xyz(x, y, z) + Normal(u, v) * ZHeight(u, v)));
            }

            return(Base.Absolut(new xyz(x, y, z)));
        }
Beispiel #14
0
        /// <summary>
        /// Overrides the Value function and implements the cone calulations.
        /// </summary>
        /// <param name="u">Specifies the u parameter int [0,1]</param>
        /// <param name="v">Specifies the v parameter int [0,1]</param>
        /// <returns>returns a xyz Point</returns>
        public override xyz Value(double u, double v)
        {
            double Factor = Radius - v * VFactor * System.Math.Tan(HalfAngle);
            double x      = System.Math.Cos(u * UFactor) * Factor;
            double y      = System.Math.Sin(u * UFactor) * Factor;
            double z      = v * VFactor;

            if (ZHeight(u, v) != 0)
            {
                return(Base.Absolut(new xyz(x, y, z) + Normal(u, v) * (ZHeight(u, v))));
            }
            else
            {
                return(Base.Absolut(new xyz(x, y, z)));
            }
        }
Beispiel #15
0
 /// <summary>
 /// overrides the <see cref="Surface.Normal(double, double)"/> method.
 /// </summary>
 /// <param name="u">the parameter u.</param>
 /// <param name="v">the parameter v.</param>
 /// <returns>the normal vector.</returns>
 public override xyz Normal(double u, double v)
 {
     double x = (Math.Cos(v * VFactor)) * Math.Cos(u * UFactor);
     double y = (System.Math.Cos(v * VFactor)) * System.Math.Sin(u * UFactor);
     double z = System.Math.Sin(v * VFactor);
     {
         if (SameSense)
         {
             return(Base.Absolut(new xyz(x, y, z)) - Base.BaseO);
         }
         else
         {
             return((Base.Absolut(new xyz(x, y, z)) - Base.BaseO) * (-1));
         }
     }
 }
Beispiel #16
0
        /// <summary>
        /// paramtisizes the sphere for the to parameters u and v which are given in the interval [0, 1]
        /// </summary>
        /// <param name="u">first parameter</param>
        /// <param name="v">second parameter</param>
        /// <returns>Spherecoordinate</returns>
        public override xyz Value(double u, double v)
        {
            double x = Radius * System.Math.Cos((u) * UFactor + 0.25 * System.Math.PI * 2) * System.Math.Sin(v * VFactor);
            double y = Radius * System.Math.Sin((u) * UFactor + 0.25 * System.Math.PI * 2) * System.Math.Sin(v * VFactor);
            double z = -Radius *System.Math.Cos(v *VFactor);

            if (ZHeight(u, v) > 0)
            {
                return(Base.Absolut(new xyz(x, y, z) +
                                    new xyz(
                                        System.Math.Cos((u) * UFactor + 0.25 * System.Math.PI * 2) * System.Math.Sin(v * VFactor),
                                        System.Math.Sin((u) * UFactor + 0.25 * System.Math.PI * 2) * System.Math.Sin(v * VFactor),
                                        -System.Math.Cos(v * VFactor)) * ZHeight(u, v)));
            }
            return(Base.Absolut(new xyz(x, y, z)));
        }
Beispiel #17
0
        /// <summary>
        /// paramtisizes the a prism for the to parameters u and v which are given in the interval [0, 1]
        /// </summary>
        /// <param name="u">first parameter</param>
        /// <param name="v">second parameter</param>
        /// <returns>prismcoordinate</returns>
        public override xyz Value(double u, double v)
        {
            int Id = (int)(u * Array.Count);

            if (Id == Array.Count)
            {
                Id--;
            }
            double _ZHeight = ZHeight(u, v);
            xy     N        = new xy(0, 0);

            if (_ZHeight > 0)
            {
                N = Normal(u * Array.Count) * _ZHeight;
            }


            return(Base.Absolut((Array.Value(u * Array.Count) + N).toXYZ() + new xyz(0, 0, v * VFactor)));
        }
Beispiel #18
0
        /// <summary>
        /// overrides the <see cref="Value(double, double)"/> method of a <see cref="Surface"/>.
        /// </summary>
        /// <param name="u">first u-parameter</param>
        /// <param name="v">second v-parameter</param>
        /// <returns>coordinate of the extruded object</returns>
        public override xyz Value(double u, double v)
        {
            double Lam = -1;
            xyz    Q   = new xyz(0, 0, 0);
            xy     P   = Curve.Value(u);
            xyz    K   = StandardBase.BaseO + StandardBase.BaseX * P.x + StandardBase.BaseY * P.y;

            if (Height < 0)
            {
                xyz Pkt  = new xyz(0, 0, 0);
                xyz Pkt2 = new xyz(0, 0, 0);
                DownPlane.Cross(new LineType(K, Direction), out Lam, out Pkt);
                UpPlane.Cross(new LineType(K, Direction), out Lam, out Pkt2);
                xyz N = Base.Absolut(Pkt + (Pkt2 - Pkt) * v);
                if (ZHeight(u, v) > 0)
                {
                    return(Base.Absolut(Pkt + (Pkt2 - Pkt) * v + Normal(u, v) * ZHeight(u, v)));
                }
                else
                {
                    return(Base.Absolut(Pkt + (Pkt2 - Pkt) * v));
                }
            }
            else
            {
                LineType L  = new LineType(K, Direction);
                Plane    PL = new Plane(Base.BaseO, Base.BaseZ);
                Q = new xyz(0, 0, 0);
                PL.Cross(L, out Lam, out Q);
                if (ZHeight(u, v) > 0)
                {
                    return(Q + Direction.normalized() * (Height * v) + Normal(u, v) * ZHeight(u, v));
                }
                else
                {
                    return(Q + Direction.normalized() * (Height * v));
                }
            }
        }
Beispiel #19
0
        /// <summary>
        /// implements the <see cref="INurbs3d.getCtrlPoints"/> method.
        /// </summary>
        /// <returns></returns>
        public override xyz[,] getCtrlPoints()
        {
            if (BoundedCurves != null)
            {
                Env = BoundedCurves[0].MaxRect;
            }
            else
            {
                Env = new RectangleF(new PointF(0, 0), new SizeF((float)Radius, (float)Height));
            }
            double Max        = Env.Y + Env.Height;
            double Min        = Env.Y;
            double BaseRadius = Radius;
            double TopR       = Radius - Height * System.Math.Tan(HalfAngle);

            TopR       = Radius - (VFactor * (System.Math.Tan(HalfAngle)));
            BaseRadius = Radius - (VFactor * (System.Math.Tan(HalfAngle) * (Min)));
            xyz[,] CP  = new xyz[, ]
            {
                { new xyz(BaseRadius, 0, Min), new xyz(TopR, 0, Max) },
                { new xyz(BaseRadius, BaseRadius, Min), new xyz(TopR, TopR, Max) },
                { new xyz(0, BaseRadius, Min), new xyz(0, TopR, Max) },
                { new xyz(-BaseRadius, BaseRadius, Min), new xyz(-TopR, TopR, Max) },
                { new xyz(-BaseRadius, 0, Min), new xyz(-TopR, 0, Max) },
                { new xyz(-BaseRadius, -BaseRadius, Min), new xyz(-TopR, -TopR, Max) },
                { new xyz(0, -BaseRadius, Min), new xyz(0, -TopR, Max) },
                { new xyz(BaseRadius, -BaseRadius, Min), new xyz(TopR, -TopR, Max) },
                { new xyz(BaseRadius, 0, Min), new xyz(TopR, 0, Max) },
            };

            for (int i = 0; i < CP.GetLength(0); i++)
            {
                for (int j = 0; j < CP.GetLength(1); j++)
                {
                    CP[i, j] = Base.Absolut(CP[i, j]);
                }
            }
            return(CP);
        }
Beispiel #20
0
        /// <summary>
        /// Overrides the method <see cref="Surface.getCross"/> and implements a method for get the crosspoint with a Line <b>L</b>, which is
        /// nearer to L.Q.
        /// </summary>
        /// <param name="L">The line, which will be crossed with the sphere</param>
        /// <param name="u">gets the u parameter of the cross point</param>
        /// <param name="v">gets the v parameter of the cross point</param>
        /// <returns>false if there is no cross point.</returns>
        public override bool getCross(LineType L, ref double u, ref double v)
        {
            xyz Direction  = L.Direction.normalized();
            xyz P          = Base.Relativ(L.P);
            xyz NDirection = ((Direction & P) & (Direction));

            double bb = NDirection.length();
            xyz    S  = new xyz(0, 0, 0);

            if (Radius > bb)
            {
                S = NDirection - Direction * System.Math.Sqrt(Radius * Radius - bb * bb);
            }
            else
            {
                return(false);
            }
            xy Param = this.ProjectPoint(Base.Absolut(S));

            u = Param.x;
            v = Param.Y;
            return(true);
        }
Beispiel #21
0
 /// <summary>
 /// Calulates the v-derivation of a bezierfunction for the two parameters u and v which are given in the interval [0, 1]
 /// </summary>
 /// <param name="u">first parameter</param>
 /// <param name="v">second parameter</param>
 /// <returns>v-derivation</returns>
 public override xyz vDerivation(double u, double v)
 {
     return(Base.Absolut(Utils.BezierSurfaceDeriveV(ControlPoints, u, v)) - Base.BaseO);
 }
Beispiel #22
0
 /// <summary>
 /// Overrides the <see cref="Curve3D.Derivation"/>-method.
 /// </summary>
 /// <param name="t"></param>
 /// <returns></returns>
 public override xyz Derivation(double t)
 {
     return(Base.Absolut(Arc.Derivation(t).toXYZ()) - Base.BaseO);
 }
Beispiel #23
0
        /// <summary>
        /// implements the <see cref="INurbs3d.getUKnots"/> method.
        /// </summary>
        /// <returns></returns>
        public override xyz[,] getCtrlPoints()
        {
            double IRSqrt = InnerRadius;// / System.Math.Sqrt(2);

            xyz[,] CP = new xyz[, ]
            {
                {
                    new xyz(OuterRadius + InnerRadius, 0, 0),
                    new xyz(OuterRadius + InnerRadius, 0, InnerRadius),
                    new xyz(OuterRadius, 0, InnerRadius),
                    new xyz(OuterRadius - InnerRadius, 0, InnerRadius),
                    new xyz(OuterRadius - InnerRadius, 0, 0),
                    new xyz(OuterRadius - InnerRadius, 0, -InnerRadius),
                    new xyz(OuterRadius, 0, -InnerRadius),
                    new xyz(OuterRadius + InnerRadius, 0, -InnerRadius),
                    new xyz(OuterRadius + InnerRadius, 0, 0),
                },

                {
                    new xyz(OuterRadius + InnerRadius, OuterRadius + InnerRadius, 0),
                    new xyz(OuterRadius + InnerRadius, OuterRadius + InnerRadius, InnerRadius),
                    new xyz(OuterRadius, OuterRadius, InnerRadius),
                    new xyz(OuterRadius - InnerRadius, OuterRadius - InnerRadius, InnerRadius),
                    new xyz(OuterRadius - InnerRadius, OuterRadius - InnerRadius, 0),
                    new xyz(OuterRadius - InnerRadius, OuterRadius - InnerRadius, -InnerRadius),
                    new xyz(OuterRadius, OuterRadius, -InnerRadius),
                    new xyz(OuterRadius + InnerRadius, OuterRadius + InnerRadius, -InnerRadius),
                    new xyz(OuterRadius + InnerRadius, OuterRadius + InnerRadius, 0),
                },

                {
                    new xyz(0, OuterRadius + InnerRadius, 0),
                    new xyz(0, OuterRadius + InnerRadius, InnerRadius),
                    new xyz(0, OuterRadius, InnerRadius),
                    new xyz(0, OuterRadius - InnerRadius, InnerRadius),
                    new xyz(0, OuterRadius - InnerRadius, 0),
                    new xyz(0, OuterRadius - InnerRadius, -InnerRadius),
                    new xyz(0, OuterRadius, -InnerRadius),
                    new xyz(0, OuterRadius + InnerRadius, -InnerRadius),
                    new xyz(0, OuterRadius + InnerRadius, 0),
                },

                {
                    new xyz(-(OuterRadius + InnerRadius), OuterRadius + InnerRadius, 0),
                    new xyz(-(OuterRadius + InnerRadius), OuterRadius + InnerRadius, InnerRadius),
                    new xyz(-OuterRadius, OuterRadius, InnerRadius),
                    new xyz(-(OuterRadius - InnerRadius), OuterRadius - InnerRadius, InnerRadius),
                    new xyz(-(OuterRadius - InnerRadius), OuterRadius - InnerRadius, 0),
                    new xyz(-(OuterRadius - InnerRadius), OuterRadius - InnerRadius, -InnerRadius),
                    new xyz(-OuterRadius, OuterRadius, -InnerRadius),
                    new xyz(-(OuterRadius + InnerRadius), OuterRadius + InnerRadius, -InnerRadius),
                    new xyz(-(OuterRadius + InnerRadius), OuterRadius + InnerRadius, 0),
                },

                {
                    new xyz(-(OuterRadius + InnerRadius), 0, 0),
                    new xyz(-(OuterRadius + InnerRadius), 0, InnerRadius),
                    new xyz(-OuterRadius, 0, InnerRadius),
                    new xyz(-(OuterRadius - InnerRadius), 0, InnerRadius),
                    new xyz(-(OuterRadius - InnerRadius), 0, 0),
                    new xyz(-(OuterRadius - InnerRadius), 0, -InnerRadius),
                    new xyz(-OuterRadius, 0, -InnerRadius),
                    new xyz(-(OuterRadius + InnerRadius), 0, -InnerRadius),
                    new xyz(-(OuterRadius + InnerRadius), 0, 0),
                },

                {
                    new xyz(-(OuterRadius + InnerRadius), -(OuterRadius + InnerRadius), 0),
                    new xyz(-(OuterRadius + InnerRadius), -(OuterRadius + InnerRadius), InnerRadius),
                    new xyz(-OuterRadius, -(OuterRadius), InnerRadius),
                    new xyz(-(OuterRadius - InnerRadius), -(OuterRadius - InnerRadius), InnerRadius),
                    new xyz(-(OuterRadius - InnerRadius), -(OuterRadius - InnerRadius), 0),
                    new xyz(-(OuterRadius - InnerRadius), -(OuterRadius - InnerRadius), -InnerRadius),
                    new xyz(-OuterRadius, -OuterRadius, -InnerRadius),
                    new xyz(-(OuterRadius + InnerRadius), -(OuterRadius + InnerRadius), -InnerRadius),
                    new xyz(-(OuterRadius + InnerRadius), -(OuterRadius + InnerRadius), 0),
                },

                {
                    new xyz(0, -(OuterRadius + InnerRadius), 0),
                    new xyz(0, -(OuterRadius + InnerRadius), InnerRadius),
                    new xyz(0, -OuterRadius, InnerRadius),
                    new xyz(0, -(OuterRadius - InnerRadius), InnerRadius),
                    new xyz(0, -(OuterRadius - InnerRadius), 0), new xyz(0, -(OuterRadius - InnerRadius), -InnerRadius),
                    new xyz(0, -OuterRadius, -InnerRadius),
                    new xyz(0, -(OuterRadius + InnerRadius), -InnerRadius),
                    new xyz(0, -(OuterRadius + InnerRadius), 0),
                },

                {
                    new xyz(OuterRadius + InnerRadius, -(OuterRadius + InnerRadius), 0),
                    new xyz(OuterRadius + InnerRadius, -(OuterRadius + InnerRadius), InnerRadius),
                    new xyz(OuterRadius, -OuterRadius, InnerRadius),
                    new xyz(OuterRadius - InnerRadius, -(OuterRadius - InnerRadius), InnerRadius),
                    new xyz(OuterRadius - InnerRadius, -(OuterRadius - InnerRadius), 0),
                    new xyz(OuterRadius - InnerRadius, -(OuterRadius - InnerRadius), -InnerRadius),
                    new xyz(OuterRadius, -OuterRadius, -InnerRadius),
                    new xyz(OuterRadius + InnerRadius, -(OuterRadius + InnerRadius), -InnerRadius),
                    new xyz(OuterRadius + InnerRadius, -(OuterRadius + InnerRadius), 0),
                },

                {
                    new xyz(OuterRadius + InnerRadius, 0, 0),
                    new xyz(OuterRadius + InnerRadius, 0, InnerRadius),
                    new xyz(OuterRadius, 0, InnerRadius),
                    new xyz(OuterRadius - InnerRadius, 0, InnerRadius),
                    new xyz(OuterRadius - InnerRadius, 0, 0),
                    new xyz(OuterRadius - InnerRadius, 0, -InnerRadius),
                    new xyz(OuterRadius, 0, -InnerRadius),
                    new xyz(OuterRadius + InnerRadius, 0, -InnerRadius),
                    new xyz(OuterRadius + InnerRadius, 0, 0),
                },
            };


            for (int i = 0; i < CP.GetLength(0); i++)
            {
                for (int j = 0; j < CP.GetLength(1); j++)
                {
                    CP[i, j] = Base.Absolut(CP[i, j]);
                }
            }


            return(CP);
        }
Beispiel #24
0
 /// <summary>
 /// Overrides the vDerivation function and implements the cone calulations.
 /// </summary>
 /// <param name="u">Specifies the u parameter int [0,1]</param>
 /// <param name="v">Specifies the v parameter int [0,1]</param>
 /// <returns>returns a xyz Point</returns>
 public override xyz vDerivation(double u, double v)
 {
     return(Base.Absolut(new xyz(0, 0, 1)) - Base.BaseO);
 }
Beispiel #25
0
 /// <summary>
 /// Calculates the partial uDerivation
 /// </summary>
 /// <param name="u">first parameter</param>
 /// <param name="v">second parameter</param>
 /// <returns>value of the partial uDerivation</returns>
 public override xyz uDerivation(double u, double v)
 {
     return(Base.Absolut(Curve.Derivation(u).toXYZ()));
 }
Beispiel #26
0
        //ControlPoints.length = Knots.Length - Order;
        //ControlPoint.Lenght = Knonot.Length- Order - 1
        /// <summary>
        /// Calculates the values for a nurbs, at the parameters u and v.
        /// </summary>
        /// <param name="u">Specifies the u parameter.</param>
        /// <param name="v">Specifies the v parameter.</param>
        /// <returns>Value of a nurbs at u,v.</returns>
        public override xyz Value(double u, double v)
        {
            try
            {
                xyz Result = new xyz(0, 0, 0);
                if ((UKnots == null) || (VKnots == null))
                {
                    return(Result);
                }
                double[] UCoeff = Utils.CoeffSpline(UKnots, ControlPoints.GetLength(0), UDegree, UPeriodicity, u);
                double[] VCoeff = Utils.CoeffSpline(VKnots, ControlPoints.GetLength(1), VDegree, VPeriodicity, v);
                int      UCount = ControlPoints.GetLength(0);
                int      VCount = ControlPoints.GetLength(1);

                {
                    double W1 = 0;

                    {
                        int VCoeffIndex = 0;
                        int uCoeffIndex = 0;

                        for (int i = 0; i < UCount; i++)
                        {
                            VCoeffIndex = 0;
                            for (int j = 0; j < VCount; j++)
                            {
                                W1 = W1 + Weights[i, j] * UCoeff[uCoeffIndex] * VCoeff[VCoeffIndex];// *VCoeffDerived[j].Value;
                                VCoeffIndex++;
                            }
                            uCoeffIndex++;
                        }
                    }

                    int uCoeffI = 0;
                    int VCoeffI = 0;

                    for (int i = 0; i < UCount; i++)
                    {
                        VCoeffI = 0;

                        for (int k = 0; k < VCount; k++)
                        {
                            Result = Result + ControlPoints[i, k] * (UCoeff[uCoeffI] * VCoeff[VCoeffI]
                                                                     * Weights[i, k] / W1);
                            VCoeffI++;
                        }
                        uCoeffI++;
                    }
                }
                return(Base.Absolut(Result));
            }
            catch (Exception)
            {
                if ((ControlPoints.GetLength(0) + UDegree + 1) != UKnots.Length)
                {
                    System.Windows.Forms.MessageBox.Show("the definition of the UKnots is wrong. It must be UKnots.Length=ControlPoints.GetLength(0) + UDegree + 1");
                }
                else
                if ((ControlPoints.GetLength(1) + VDegree + 1) != VKnots.Length)
                {
                    System.Windows.Forms.MessageBox.Show("the definition of the VKnots is wrong. It must be VKnots.Length=ControlPoints.GetLength(1) + VDegree + 1");
                }
                return(Base.BaseO);
            }
        }
Beispiel #27
0
        /// <summary>
        /// Calculates the partial v derivation of the <see cref="BSplineSurface"/>.
        /// </summary>
        /// <param name="u">Parameter u.</param>
        /// <param name="v">Parameter v.</param>
        /// <returns>The partial v derivation.</returns>
        public override xyz vDerivation(double u, double v)
        {
            try
            {
                xyz      Result = new xyz(0, 0, 0);
                double[] UCoeff = Utils.CoeffSpline(UKnots, ControlPoints.GetLength(0), UDegree, UPeriodicity, v);
                double[] VCoeff = Utils.CoeffSpline(VKnots, ControlPoints.GetLength(1), VDegree, VPeriodicity, u);
                Utils.SplineExValue[] VCoeffDerived = Utils.CoeffSplineEx(VKnots, ControlPoints.GetLength(1), VDegree, VPeriodicity, u);

                int FirstUCoeffNonZero = 0;
                for (int i = 0; i < UCoeff.Length; i++)
                {
                    if (UCoeff[i] != 0)
                    {
                        FirstUCoeffNonZero = i;
                        break;
                    }
                }

                int FirstVCoeffNonZero = 0;
                for (int i = 0; i < VCoeffDerived.Length; i++)
                {
                    if (VCoeffDerived[i].Value != 0)
                    {
                        FirstVCoeffNonZero = i;
                        break;
                    }
                }
                int UntilU = Math.Min(FirstUCoeffNonZero + UDegree, UCoeff.Length - 1);
                int UntilV = Math.Min(FirstVCoeffNonZero + VDegree, VCoeffDerived.Length - 1);
                // Derivation without Weigths
                for (int i = FirstUCoeffNonZero; i <= UntilU; i++)
                {
                    for (int k = FirstVCoeffNonZero; k <= UntilV; k++)

                    {
                        Result = Result + ControlPoints[i, k] * (VCoeffDerived[k].Derivation * UCoeff[i]);
                    }
                }

                // Derivation width Weigth

                // noch machen

                return(Base.Absolut(Result) - Base.BaseO);
            }
            catch (Exception)
            {
                if ((ControlPoints.GetLength(0) + UDegree + 1) != UKnots.Length)
                {
                    System.Windows.Forms.MessageBox.Show("the definition of the UKnots is wrong.");
                }
                else
                if ((ControlPoints.GetLength(1) + VDegree + 1) != VKnots.Length)
                {
                    System.Windows.Forms.MessageBox.Show("the definition of the VKnots is wrong.");
                }
                System.Windows.Forms.Application.Exit();
                return(new xyz(0, 0, 0));
            }
        }
Beispiel #28
0
        /// <summary>
        /// Calculates the value of the <see cref="BSplineSurface"/>.
        /// </summary>
        /// <param name="u">Parameter u.</param>
        /// <param name="v">Parameter v.</param>
        /// <returns>The Evaluation of the bspline.</returns>
        public override xyz Value(double u, double v)
        {
            try
            {
                if (UKnots == null)
                {
                    UKnots = Utils.StandardKnots(ControlPoints.GetLength(0), UDegree);
                }
                if (VKnots == null)
                {
                    VKnots = Utils.StandardKnots(ControlPoints.GetLength(1), VDegree);
                }
                Rectangled R = DefinitionDomain;

                xyz Result = new xyz(0, 0, 0);

                int      UCount             = ControlPoints.GetLength(0);
                int      VCount             = ControlPoints.GetLength(1);
                double[] UCoeff             = Utils.CoeffSpline(UKnots, UCount, UDegree, UPeriodicity, v);
                double[] VCoeff             = Utils.CoeffSpline(VKnots, VCount, VDegree, VPeriodicity, u);
                int      FirstUCoeffNonZero = 0;
                for (int i = 0; i < UCoeff.Length; i++)
                {
                    if (UCoeff[i] != 0)
                    {
                        FirstUCoeffNonZero = i;
                        break;
                    }
                }

                int FirstVCoeffNonZero = 0;
                for (int i = 0; i < VCoeff.Length; i++)
                {
                    if (VCoeff[i] != 0)
                    {
                        FirstVCoeffNonZero = i;
                        break;
                    }
                }
                int UntilU = Math.Min(FirstUCoeffNonZero + UDegree, UCoeff.Length - 1);
                int UntilV = Math.Min(FirstVCoeffNonZero + VDegree, VCoeff.Length - 1);

                for (int i = 0; i < UCoeff.Length; i++)
                {
                    for (int k = 0; k < VCoeff.Length; k++)

                    {
                        Result = Result + ControlPoints[i, k] * (UCoeff[i] * VCoeff[k]);
                    }
                }
                if (ZHeight(u, v) != 0)
                {
                    return(Base.Absolut(Result + Normal(u, v) * ZHeight(u, v)));
                }
                else
                {
                    return(Base.Absolut(Result));
                }
            }
            catch (Exception)
            {
                if ((ControlPoints.GetLength(0) + UDegree + 1) != UKnots.Length)
                {
                    System.Windows.Forms.MessageBox.Show("the definition of the UKnots is wrong. . It must be UKnots.Length=ControlPoints.GetLength(0) + UDegree + 1");
                }
                else
                if ((ControlPoints.GetLength(1) + VDegree + 1) != VKnots.Length)
                {
                    System.Windows.Forms.MessageBox.Show("the definition of the VKnots is wrong. It must be VKnots.Length=ControlPoints.GetLength(1) + VDegree + 1");
                }

                return(new xyz(0, 0, 0));
            }
        }
Beispiel #29
0
 /// <summary>
 /// Overrides the<see cref="Surface.Value(double, double)"/> method.
 /// </summary>
 /// <param name="u">Specifies the u parameter int [0,1]</param>
 /// <param name="v">Specifies the v parameter int [0,1]</param>
 /// <returns>returns a xyz Point</returns>
 public override xyz Value(double u, double v)
 {
     return(Base.Absolut(new xyz(u * UFactor, v * VFactor, ZHeight(u, v))));
 }
Beispiel #30
0
 /// <summary>
 /// Overrides the value function and implement the circle function. For a full Circle you have to take the parameter from 0 to 1.
 /// 1 is equivalent to 2*PI.
 /// </summary>
 /// <param name="t">a Parameter</param>
 /// <returns></returns>
 public override xyz Value(double t)
 {
     return(Base.Absolut(Arc.Value(t).toXYZ()));
 }