perpendicular() приватный Метод

private perpendicular ( Vector2 original ) : Vector2
original Microsoft.Xna.Framework.Vector2
Результат Microsoft.Xna.Framework.Vector2
Пример #1
0
        public static void drawCircle(
            this SpriteBatch spriteBatch,
            Vector2 position,
            float radius,
            Color color,
            float thickness = 1f,
            int resolution  = 12)
        {
            var last  = Vector2.UnitX * radius;
            var lastP = Vector2Ext.perpendicular(last);

            for (int i = 1; i <= resolution; i++)
            {
                var at  = Mathf.angleToVector(i * MathHelper.PiOver2 / resolution, radius);
                var atP = Vector2Ext.perpendicular(at);

                drawLine(spriteBatch, position + last, position + at, color, thickness);
                drawLine(spriteBatch, position - last, position - at, color, thickness);
                drawLine(spriteBatch, position + lastP, position + atP, color, thickness);
                drawLine(spriteBatch, position - lastP, position - atP, color, thickness);

                last  = at;
                lastP = atP;
            }
        }
Пример #2
0
        public static void drawCircle(
            this Batcher batcher,
            Vector2 position,
            float radius,
            Color color,
            float thickness = 1f,
            int resolution  = 12)
        {
            var last  = Vector2.UnitX * radius;
            var lastP = Vector2Ext.perpendicular(last);

            batcher.setIgnoreRoundingDestinations(true);
            for (int i = 1; i <= resolution; i++)
            {
                var at  = Mathf.angleToVector(i * MathHelper.PiOver2 / resolution, radius);
                var atP = Vector2Ext.perpendicular(at);

                drawLine(batcher, position + last, position + at, color, thickness);
                drawLine(batcher, position - last, position - at, color, thickness);
                drawLine(batcher, position + lastP, position + atP, color, thickness);
                drawLine(batcher, position - lastP, position - atP, color, thickness);

                last  = at;
                lastP = atP;
            }

            batcher.setIgnoreRoundingDestinations(false);
        }