示例#1
0
        public static Vector2 PointOnCircle(Vector2 circleCenter, float radius, float angleInDegrees)
        {
            float radians = MathExtension.DegreesToRadians(angleInDegrees);

            return(new Vector2
            {
                X = Cos(radians) * radius + circleCenter.X,
                Y = Sin(radians) * radius + circleCenter.Y
            });
        }
示例#2
0
        public static Vector2 RotateAround(Vector2 point, Vector2 center, float angleInDegrees)
        {
            angleInDegrees = MathExtension.DegreesToRadians(angleInDegrees);
            float cos      = Cos(angleInDegrees);
            float sin      = Sin(angleInDegrees);
            float rotatedX = cos * (point.X - center.X) - sin * (point.Y - center.Y) + center.X;
            float rotatedY = sin * (point.X - center.X) + cos * (point.Y - center.Y) + center.Y;

            return(new Vector2(rotatedX, rotatedY));
        }