开发者

Increase distance when draw a ellipse

开发者 https://www.devze.com 2023-03-17 07:39 出处:网络
How can i increase the distance when i draw a ellipse from a certain point? This is the code i use to draw a ellipse in c#:

How can i increase the distance when i draw a ellipse from a certain point? This is the code i use to draw a ellipse in c#:

public double[] CalculatePosition(double centerX, double centerY, double angle)
{
    double[] position = new double[2];
    position[0] = Math.Cos(angle) * radiusX + centerX;
    position[1] = Math.Sin(angle) * radiusY + centerY;
    return position;
}

draw a ellipse base开发者_StackOverflowd on a point. the function that use this, draw for example 5 ellipses, around the point.


Do you mean the size of the eclipse? In which case, you want to vary radiusX and radiusY.

The best way to do this is to pass them as parameters to the function:

public double[] CalculatePosition(double centerX, 
                                 double centerY, 
                                 double radiusX,
                                 double radiusY,
                                 double angle)
{
    double[] position = new double[2];
    position[0] = Math.Cos(angle) * radiusX + centerX;
    position[1] = Math.Sin(angle) * radiusY + centerY;
    return position;
}

Then you can draw several ellipses around the same point by calling this function several times, and varying radiusX and radiusY.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号