Beispiel #1
0
        protected bool allocBonesInBones(string mainname, string bonename, BaseObject parent, Vector3D vec = new Vector3D(), Vector3D vecMulti = new Vector3D(), Vector3D vecBone = new Vector3D(), Vector3D vecBoneMulti = new Vector3D(), long counter = 0)
        {
            int KnochenLinks;
            int bone = (int)counter;

            if (bone != 0)
            {
                while (bone != 0)
                {
                    BaseObject jointBone = this.allocJoint(mainname + "_" + bone, parent, new Vector3D(vec.X += vecMulti.X, vec.Y += vecMulti.Y, vec.Z += vecMulti.Z));
                    //BaseObject jointBone = this.allocJoint(mainname +"_"+ bone, parent, new Vector3D(vec.X, vec.Y, vec.Z + bone_z));
                    this.wtag.AddJoint(jointBone);

                    if (bone == 1)
                    {
                        KnochenLinks = 2;
                    }
                    else
                    {
                        KnochenLinks = 3;
                    }

                    while (KnochenLinks != 0)
                    {
                        jointBone = this.allocJoint(bonename + "_" + KnochenLinks, jointBone, new Vector3D(vecBone.X += vecBoneMulti.X, vecBone.Y += vecBoneMulti.Y, vecBone.Z += vecBoneMulti.Z));
                        this.wtag.AddJoint(jointBone);
                        KnochenLinks--;
                    }
                    bone--;
                }
            }
            return true;
        }
        protected BaseObject allocBonesCurveY(string mainname, BaseObject parent, long counter = 0, Vector3D vec = new Vector3D())
        {
            int bone = (int)counter;
            BaseObject myJoint = null;
            double x = vec.X;
            double y = vec.Y;
            if (x < 0)
            {
                x *= -1;
            }
            while (bone > 0)
            {
                vec.Y += x / bone;
                if (vec.Y > x)
                {
                    vec.Y = x;
                }
                myJoint = this.allocJoint(mainname, parent, vec);
                this.wtag.AddJoint(myJoint);
                vec.X += vec.Y;
                if (vec.X > 0)
                {
                    vec.X = 0;
                }

                parent = myJoint;
                bone--;
            }
            return myJoint;
        }
Beispiel #3
0
        static Vector3D SwapPoint(Vector3D p, int plane)
        {
	        switch (plane)
	        {
                case 1: return new Vector3D(-p.X, p.Y, p.Z);
                case 2: return new Vector3D(p.X, -p.Y, p.Z);
	        }
	        return p;
        }
Beispiel #4
0
 /**
  * Anlegen eines Joint Objekts
  * @param string Name des Joint Objekts
  * @param BaseObject Parent Joint, falls dieser gekuppelt werden soll
  * @param Vector3D Vektor in die der Joint zeigen soll
  * @return BaseObject Joint Objekt zurückgeben
  */
 protected BaseObject allocJoint(string name, BaseObject parentJoint = null, Vector3D vec = new Vector3D())
 {
     BaseObject myJoint = BaseObject.Alloc(C4dApi.Ojoint); // Speicher reservieren für den Joint
     myJoint.SetName(name); // Joint mit einem Namen versehen
     if (parentJoint == null)
     {
         parentJoint = this.myMesh;
     }
     this.doc.InsertObject(myJoint, parentJoint, null); // Kuppeln der Joints
     myJoint.SetAbsPos(vec); // Richtung vorgeben
     return myJoint;
 }
 /// <summary>
 /// Subtracts a scalar from a vector and put the result into another vector.
 /// </summary>
 /// <param name="u">A <see cref="Vector3D"/> instance.</param>
 /// <param name="s">A scalar.</param>
 /// <param name="v">A <see cref="Vector3D"/> instance to hold the result.</param>
 /// <remarks>
 /// v[i] = s - u[i]
 /// </remarks>
 public static void Subtract(double s, Vector3D u, ref Vector3D v)
 {
     v.X = s - u.X;
     v.Y = s - u.Y;
     v.Z = s - u.Z;
 }
 /// <summary>
 /// Subtracts a vector from a second vector and puts the result into a third vector.
 /// </summary>
 /// <param name="u">A <see cref="Vector3D"/> instance.</param>
 /// <param name="v">A <see cref="Vector3D"/> instance</param>
 /// <param name="w">A <see cref="Vector3D"/> instance to hold the result.</param>
 /// <remarks>
 ///	w[i] = v[i] - w[i].
 /// </remarks>
 public static void Subtract(Vector3D u, Vector3D v, ref Vector3D w)
 {
     w.X = u.X - v.X;
     w.Y = u.Y - v.Y;
     w.Z = u.Z - v.Z;
 }
 /// <summary>
 /// Subtracts a scalar from a vector.
 /// </summary>
 /// <param name="v">A <see cref="Vector3D"/> instance.</param>
 /// <param name="s">A scalar.</param>
 /// <returns>A new <see cref="Vector3D"/> instance containing the difference.</returns>
 /// <remarks>
 /// result[i] = v[i] - s
 /// </remarks>
 public static Vector3D Subtract(Vector3D v, double s)
 {
     return new Vector3D(v.X - s, v.Y - s, v.Z - s);
 }
 /// <summary>
 /// Negates a vector.
 /// </summary>
 /// <param name="v">A <see cref="Vector3D"/> instance.</param>
 /// <returns>A new <see cref="Vector3D"/> instance containing the negated values.</returns>
 public static Vector3D Negate(Vector3D v)
 {
     return new Vector3D(-v.X, -v.Y, -v.Z);
 }
 /// <summary>
 /// Multiplies a vector by a scalar.
 /// </summary>
 /// <param name="u">A <see cref="Vector3D"/> instance.</param>
 /// <param name="s">A scalar.</param>
 /// <returns>A new <see cref="Vector3D"/> containing the result.</returns>
 public static Vector3D Multiply(Vector3D u, double s)
 {
     return new Vector3D(u.X * s, u.Y * s, u.Z * s);
 }
 /// <summary>
 /// Divides a scalar by a vector.
 /// </summary>
 /// <param name="u">A <see cref="Vector3D"/> instance.</param>
 /// <param name="s">A scalar</param>
 /// <param name="v">A <see cref="Vector3D"/> instance to hold the result.</param>
 /// <remarks>
 /// v[i] = s / u[i]
 /// </remarks>
 public static void Divide(double s, Vector3D u, ref Vector3D v)
 {
     v.X = s / u.X;
     v.Y = s / u.Y;
     v.Z = s / u.Z;
 }
 /// <summary>
 /// Adds a vector and a scalar and put the result into another vector.
 /// </summary>
 /// <param name="u">A <see cref="Vector3D"/> instance.</param>
 /// <param name="s">A scalar.</param>
 /// <param name="v">A <see cref="Vector3D"/> instance to hold the result.</param>
 public static void Add(Vector3D u, double s, ref Vector3D v)
 {
     v.X = u.X + s;
     v.Y = u.Y + s;
     v.Z = u.Z + s;
 }
 /// <summary>
 /// Adds two vectors and put the result in the third vector.
 /// </summary>
 /// <param name="u">A <see cref="Vector3D"/> instance.</param>
 /// <param name="v">A <see cref="Vector3D"/> instance</param>
 /// <param name="w">A <see cref="Vector3D"/> instance to hold the result.</param>
 public static void Add(Vector3D u, Vector3D v, ref Vector3D w)
 {
     w.X = u.X + v.X;
     w.Y = u.Y + v.Y;
     w.Z = u.Z + v.Z;
 }
 /// <summary>
 /// Adds a vector and a scalar.
 /// </summary>
 /// <param name="v">A <see cref="Vector3D"/> instance.</param>
 /// <param name="s">A scalar.</param>
 /// <returns>A new <see cref="Vector3D"/> instance containing the sum.</returns>
 public static Vector3D Add(Vector3D v, double s)
 {
     return new Vector3D(v.X + s, v.Y + s, v.Z + s);
 }
 /// <summary>
 /// Adds two vectors.
 /// </summary>
 /// <param name="v">A <see cref="Vector3D"/> instance.</param>
 /// <param name="w">A <see cref="Vector3D"/> instance.</param>
 /// <returns>A new <see cref="Vector3D"/> instance containing the sum.</returns>
 public static Vector3D Add(Vector3D v, Vector3D w)
 {
     return new Vector3D(v.X + w.X, v.Y + w.Y, v.Z + w.Z);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="Vector3D"/> class using coordinates from a given <see cref="Vector3D"/> instance.
 /// </summary>
 /// <param name="vector">A <see cref="Vector3D"/> to get the coordinates from.</param>
 public Vector3D(Vector3D vector)
 {
     _x = vector.X;
     _y = vector.Y;
     _z = vector.Z;
 }
 /// <summary>
 /// Divides a vector by another vector.
 /// </summary>
 /// <param name="u">A <see cref="Vector3D"/> instance.</param>
 /// <param name="v">A <see cref="Vector3D"/> instance.</param>
 /// <param name="w">A <see cref="Vector3D"/> instance to hold the result.</param>
 /// <remarks>
 /// w[i] = u[i] / v[i]
 /// </remarks>
 public static void Divide(Vector3D u, Vector3D v, ref Vector3D w)
 {
     w.X = u.X / v.X;
     w.Y = u.Y / v.Y;
     w.Z = u.Z / v.Z;
 }
 /// <summary>
 /// Divides a vector by a scalar.
 /// </summary>
 /// <param name="u">A <see cref="Vector3D"/> instance.</param>
 /// <param name="s">A scalar</param>
 /// <param name="v">A <see cref="Vector3D"/> instance to hold the result.</param>
 /// <remarks>
 /// v[i] = u[i] / s
 /// </remarks>
 public static void Divide(Vector3D u, double s, ref Vector3D v)
 {
     v.X = u.X / s;
     v.Y = u.Y / s;
     v.Z = u.Z / s;
 }
 /// <summary>
 /// Tests whether two vectors are approximately equal using default tolerance value.
 /// </summary>
 /// <param name="v">A <see cref="Vector3D"/> instance.</param>
 /// <param name="u">A <see cref="Vector3D"/> instance.</param>
 /// <returns><see langword="true"/> if the two vectors are approximately equal; otherwise, <see langword="false"/>.</returns>
 public static bool ApproxEqual(Vector3D v, Vector3D u)
 {
     return ApproxEqual(v,u, MathFunctions.EpsilonD);
 }
 /// <summary>
 /// Calculates the dot product of two vectors.
 /// </summary>
 /// <param name="u">A <see cref="Vector3D"/> instance.</param>
 /// <param name="v">A <see cref="Vector3D"/> instance.</param>
 /// <returns>The dot product value.</returns>
 public static double Dot(Vector3D u, Vector3D v)
 {
     return (u.X * v.X) + (u.Y * v.Y) + (u.Z * v.Z);
 }
 /// <summary>
 /// Tests whether two vectors are approximately equal given a tolerance value.
 /// </summary>
 /// <param name="v">A <see cref="Vector3D"/> instance.</param>
 /// <param name="u">A <see cref="Vector3D"/> instance.</param>
 /// <param name="tolerance">The tolerance value used to test approximate equality.</param>
 /// <returns><see langword="true"/> if the two vectors are approximately equal; otherwise, <see langword="false"/>.</returns>
 public static bool ApproxEqual(Vector3D v, Vector3D u, double tolerance)
 {
     return
         (
         (System.Math.Abs(v.X - u.X) <= tolerance) &&
         (System.Math.Abs(v.Y - u.Y) <= tolerance) &&
         (System.Math.Abs(v.Z - u.Z) <= tolerance)
         );
 }
 /// <summary>
 /// Multiplies a vector by a scalar and put the result in another vector.
 /// </summary>
 /// <param name="u">A <see cref="Vector3D"/> instance.</param>
 /// <param name="s">A scalar.</param>
 /// <param name="v">A <see cref="Vector3D"/> instance to hold the result.</param>
 public static void Multiply(Vector3D u, double s, ref Vector3D v)
 {
     v.X = u.X * s;
     v.Y = u.Y * s;
     v.Z = u.Z * s;
 }
 /// <summary>
 /// Calculates the cross product of two vectors.
 /// </summary>
 /// <param name="u">A <see cref="Vector3D"/> instance.</param>
 /// <param name="v">A <see cref="Vector3D"/> instance.</param>
 /// <returns>A new <see cref="Vector3D"/> containing the cross product result.</returns>
 public static Vector3D CrossProduct(Vector3D u, Vector3D v)
 {
     return new Vector3D(
         u.Y*v.Z - u.Z*v.Y,
         u.Z*v.X - u.X*v.Z,
         u.X*v.Y - u.Y*v.X );
 }
 /// <summary>
 /// Subtracts a vector from a vector.
 /// </summary>
 /// <param name="v">A <see cref="Vector3D"/> instance.</param>
 /// <param name="w">A <see cref="Vector3D"/> instance.</param>
 /// <returns>A new <see cref="Vector3D"/> instance containing the difference.</returns>
 /// <remarks>
 ///	result[i] = v[i] - w[i].
 /// </remarks>
 public static Vector3D Subtract(Vector3D v, Vector3D w)
 {
     return new Vector3D(v.X - w.X, v.Y - w.Y, v.Z - w.Z);
 }
 /// <summary>
 /// Calculates the cross product of two vectors.
 /// </summary>
 /// <param name="u">A <see cref="Vector3D"/> instance.</param>
 /// <param name="v">A <see cref="Vector3D"/> instance.</param>
 /// <param name="w">A <see cref="Vector3D"/> instance to hold the cross product result.</param>
 public static void CrossProduct(Vector3D u, Vector3D v, ref Vector3D w)
 {
     w.X = u.Y*v.Z - u.Z*v.Y;
     w.Y = u.Z*v.X - u.X*v.Z;
     w.Z = u.X*v.Y - u.Y*v.X;
 }
 /// <summary>
 /// Subtracts a vector from a scalar.
 /// </summary>
 /// <param name="v">A <see cref="Vector3D"/> instance.</param>
 /// <param name="s">A scalar.</param>
 /// <returns>A new <see cref="Vector3D"/> instance containing the difference.</returns>
 /// <remarks>
 /// result[i] = s - v[i]
 /// </remarks>
 public static Vector3D Subtract(double s, Vector3D v)
 {
     return new Vector3D(s - v.X, s - v.Y, s - v.Z);
 }
 /// <summary>
 /// Divides a vector by another vector.
 /// </summary>
 /// <param name="u">A <see cref="Vector3D"/> instance.</param>
 /// <param name="v">A <see cref="Vector3D"/> instance.</param>
 /// <returns>A new <see cref="Vector3D"/> containing the quotient.</returns>
 /// <remarks>
 ///	result[i] = u[i] / v[i].
 /// </remarks>
 public static Vector3D Divide(Vector3D u, Vector3D v)
 {
     return new Vector3D(u.X / v.X, u.Y / v.Y, u.Z / v.Z);
 }
 /// <summary>
 /// Subtracts a vector from a scalar and put the result into another vector.
 /// </summary>
 /// <param name="u">A <see cref="Vector3D"/> instance.</param>
 /// <param name="s">A scalar.</param>
 /// <param name="v">A <see cref="Vector3D"/> instance to hold the result.</param>
 /// <remarks>
 /// v[i] = u[i] - s
 /// </remarks>
 public static void Subtract(Vector3D u, double s, ref Vector3D v)
 {
     v.X = u.X - s;
     v.Y = u.Y - s;
     v.Z = u.Z - s;
 }
 /// <summary>
 /// Divides a vector by a scalar.
 /// </summary>
 /// <param name="v">A <see cref="Vector3D"/> instance.</param>
 /// <param name="s">A scalar</param>
 /// <returns>A new <see cref="Vector3D"/> containing the quotient.</returns>
 /// <remarks>
 /// result[i] = v[i] / s;
 /// </remarks>
 public static Vector3D Divide(Vector3D v, double s)
 {
     return new Vector3D(v.X / s, v.Y / s, v.Z / s);
 }
 /// <summary>
 /// Returns a new <see cref="Vector3D"/> instance representing the unit vector of the current vector.
 /// </summary>
 /// <returns>A <see cref="Vector3D"/> instance.</returns>
 public Vector3D GetUnit()
 {
     Vector3D result = new Vector3D(this);
     result.Normalize();
     return result;
 }
 /// <summary>
 /// Divides a scalar by a vector.
 /// </summary>
 /// <param name="v">A <see cref="Vector3D"/> instance.</param>
 /// <param name="s">A scalar</param>
 /// <returns>A new <see cref="Vector3D"/> containing the quotient.</returns>
 /// <remarks>
 /// result[i] = s / v[i]
 /// </remarks>
 public static Vector3D Divide(double s, Vector3D v)
 {
     return new Vector3D(s / v.X, s/ v.Y, s / v.Z);
 }