コード例 #1
0
ファイル: MathUtil.cs プロジェクト: zdam/SilverWeightPhone
        /// <summary> Subtract one vector from another
        /// 
        /// </summary>
        /// <param name="a">The vector to be subtracted from
        /// </param>
        /// <param name="b">The vector to subtract
        /// </param>
        /// <returns> A newly created containing the result
        /// </returns>
        public static Vector2f Sub(ROVector2f a, ROVector2f b)
        {
            Vector2f temp = new Vector2f(a);
            temp.Sub(b);

            return temp;
        }
コード例 #2
0
ファイル: MathUtil.cs プロジェクト: zdam/SilverWeightPhone
        /// <summary> Get the normal of a line x y (or edge). 
        /// When standing on x facing y, the normal will point
        /// to the left.
        /// 
        /// TODO: Move this function somewhere else?
        /// 
        /// </summary>
        /// <param name="x">startingpoint of the line
        /// </param>
        /// <param name="y">endpoint of the line
        /// </param>
        /// <returns> a (normalised) normal
        /// </returns>
        public static Vector2f GetNormal(ROVector2f x, ROVector2f y)
        {
            Vector2f normal = new Vector2f(y);
            normal.Sub(x);

            normal = new Vector2f(normal.y, - normal.x);
            normal.Normalise();

            return normal;
        }