コード例 #1
0
ファイル: Math.cs プロジェクト: nicolasazrak/RenderMan
 public static float getDegree(Vector2 v1, Vector2 v2)
 {
     return (float)Math.Acos(Vector2.Dot(v1, v2) / Math.Abs(v1.LengthSq() * v2.LengthSq()));
 }
コード例 #2
0
ファイル: XInputDotNet.cs プロジェクト: glenstevens/wow360
        private static Vector2 apply_thresh_2d(int xval, int yval, int thresh, int max)
        {
            Vector2 pos = new Vector2((float)xval, (float)yval);
            if (pos.LengthSq() < thresh * thresh)
                return new Vector2(0.0f, 0.0f);

            Vector2 n = pos;
            n.Normalize();
            n *= (float)thresh;
            pos -= n;
            pos *= 1.0f / (float)(max - thresh);
            return pos;
        }