Exemple #1
0
        private float animateArrestingWire(SceneNode arrestingWire, float targetWorldXPos)
        {
            float     lastH;
            SceneNode lWire = (SceneNode)arrestingWire.GetChild(0);
            SceneNode rWire = (SceneNode)arrestingWire.GetChild(1);
            SceneNode temp;

            // fix zamienione nody
            if (rWire.Name.StartsWith(name + "_LArrestingWire"))
            {
                temp  = lWire;
                lWire = rWire;
                rWire = temp;
            }

            lastH = lWire._getDerivedPosition().x - targetWorldXPos;
            Radian alpha  = Math.ATan(lastH / (0.5f * arrestingWiresSpan)); // k¹t wychylenia kawalkow liny
            float  length = lastH / Math.Sin(alpha);                        // dlugosc liny

            lWire.Orientation  = new Quaternion(Math.HALF_PI, Vector3.UNIT_X);
            lWire.Orientation *= new Quaternion(Math.HALF_PI, Vector3.UNIT_Z);
            lWire.Orientation *= new Quaternion(alpha, Vector3.NEGATIVE_UNIT_Z);
            lWire.SetScale(1, length, 1);

            rWire.Orientation  = new Quaternion(Math.HALF_PI, Vector3.UNIT_X);
            rWire.Orientation *= new Quaternion(Math.HALF_PI, Vector3.NEGATIVE_UNIT_Z);
            rWire.Orientation *= new Quaternion(alpha, Vector3.UNIT_Z);
            rWire.SetScale(1, length, 1);

            return(lastH);
        }
Exemple #2
0
        /// <summary>
        /// Zwiêksza odleg³oœæ punktu od punktu (0,0), nie zmieniaj¹c k¹ta nachylenia.
        /// </summary>
        /// <param name="length">D³ugoœæ o jak¹ ma byæ przesuniêty punkt.</param>
        public void Extend(float length)
        {
            //tworzê wektor o kierunku zgodnym z danym punktem i d³ugoœci¹ lenght
            PointD addVector = new PointD(Math.Cos(Angle) * length, Math.Sin(Angle) * length);

            Move(addVector);
        }
        /// Builds the shape
        public Shape realizeShape()
        {
            Radian alpha = Math.ACos((mLengthB * mLengthB + mLengthC * mLengthC - mLengthA * mLengthA) / (2 * mLengthB * mLengthC));

            Shape s = new Shape();

            s.addPoint(0.0f, 0.0f);
            s.addPoint(Math.Cos(alpha) * mLengthB, Math.Sin(alpha) * mLengthB);
            s.addPoint(mLengthC, 0.0f);
            s.close();
            s.translate((Math.Cos(alpha) * mLengthB + mLengthC) / -3.0f, mLengthB / -3.0f);

            return(s);
        }
Exemple #4
0
        /// <summary>
        /// Obraca punkt o kat angle wzgledem punktu rotateCenter.
        /// </summary>
        /// <param name="rotateCenter">Srodek obrotu</param>
        /// <param name="angle">Kat o ktory, chcemy obrocic (podany w radianach).</param>
        /// <author>Emil</author>
        public void Rotate(PointD rotateCenter, float angle)
        {
            if (rotateCenter == this)
            {
                return;
            }
            //mX = (mX - rotateCenter.mX) * Math.Cos(angle) + rotateCenter.mX - (mY - rotateCenter.mY) * Math.Sin(angle);
            //mY = (mX - rotateCenter.mX) * Math.Sin(angle) + (mY - rotateCenter.mY) * Math.Cos(angle) + rotateCenter.mY;

            Move(-1 * rotateCenter);
            float oldX = mX,
                  oldY = mY;

            mX = oldX * Math.Cos(angle) - oldY * Math.Sin(angle);
            mY = oldX * Math.Sin(angle) + oldY * Math.Cos(angle);
            Move(rotateCenter);
        }
Exemple #5
0
 protected override float animationFunction(float x)
 {
     return(Math.Abs(Math.Sin(x)));
 }
Exemple #6
0
 protected float sinf(float a)
 {
     return(Math.Sin(a));
 }
Exemple #7
0
 /// <summary>
 /// Rotates the specified vector clockwise by the specified angle, in radians
 /// </summary>
 /// <param name="vec">The vector2 to rotate</param>
 /// <param name="radians">The number of radians to rotate clockwise by</param>
 /// <returns>The rotated vector</returns>
 public static Vector2 RotateVector2(Vector2 vec, float rad)
 {
     return(new Vector2(vec.x * Math.Cos(rad) + vec.y * Math.Sin(rad), vec.x * Math.Sin(rad) - vec.y * Math.Cos(rad)));
 }
        //    *
        //	 * Builds a shape from control points
        //
        //-----------------------------------------------------------------------
        public Path realizePath()
        {
            Path  helix      = new Path();
            float angleStep  = Math.TWO_PI / (float)(mNumSegPath);
            float heightStep = mHeight / (float)(mNumSegPath);

            for (int i = 0; i < mNumRound * mNumSegPath; i++)
            {
                helix.addPoint(mRadius * Math.Cos(angleStep * i), heightStep * i, mRadius * Math.Sin(angleStep * i));
            }

            return(helix);
        }
 //----add
 private float sinf(float p)
 {
     return(Math.Sin(p));
 }
Exemple #10
0
        // Rotates a Vector2 by a given oriented angle
        public static Vector2 rotateVector2(Vector2 @in, Radian angleR)
        {
            float angle = angleR.ValueRadians;

            return(new Vector2(@in.x * (float)Math.Cos(angle) - @in.y * (float)Math.Sin(angle), @in.x * (float)Math.Sin(angle) + @in.y * (float)Math.Cos(angle)));
        }
 private float sin(float p)
 {
     return(Math.Sin(p));//throw new NotImplementedException();
 }