c# - Points on a circle by angle not spaced evenly -



c# - Points on a circle by angle not spaced evenly -

this question has reply here:

finding points on perimeter of circle 1 reply

given:

x = originx + radius * cos(angle);

y = originy + radius * sin(angle);

why points not evenly distributed around border of circle?

image of result:

class circle { public vector2 origin { get; set; } public float radius { get; set; } public list<vector2> points { get; set; } private texture2d _texture; public circle(float radius, vector2 origin, contentmanager content) { radius = radius; origin = origin; _texture = content.load<texture2d>("pixel"); points = new list<vector2>(); //i = angle (int = 0; < 360; i++) { float x = origin.x + radius * (float)math.cos(i); float y = origin.y + radius * (float)math.sin(i); points.add(new vector2(x, y)); } } public void draw(spritebatch spritebatch) { (int = 0; < points.count; i++) spritebatch.draw(_texture, points[i], new rectangle(0, 0, _texture.width, _texture.height), color.red); } }

math.cos , math.sin take angle in radians opposed degrees, code should be:

float x = origin.x + radius * (float)math.cos(i*math.pi/180.0); float y = origin.y + radius * (float)math.sin(i*math.pi/180.0);

c# xna circle angle

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -