1
\$\begingroup\$

I know circle formula and know how to draw it. but I want put 4 points on it with equal distance from each other. how can I do that?

I work with unity.

\$\endgroup\$
2
  • \$\begingroup\$ This solves it: answers.unity.com/questions/714835/… \$\endgroup\$ Commented Jul 17, 2018 at 17:41
  • \$\begingroup\$ @LinkWindcrafter thanks. I had to guess. I have to use traigonometry \$\endgroup\$ Commented Jul 17, 2018 at 17:44

1 Answer 1

2
\$\begingroup\$

It sounds like you want to make a regular polygon. It also sounds like you're talking about 2D space, but just for fun, here's a way to do that for any number of points and any arbitrary circle in 3D space:

public Vector3[] circlePoints (int n, float radius, Vector3 center, Vector3 normal) {
    var points = new Vector3[n];

    Vector3 offset = Vector3.ProjectOnPlane(Vector3.right, normal).normalized * radius;
    float angle = 0;

    for (int i = 0; i < n; i++) {
        Vector3 rotatedOffset = Quaternion.AngleAxis(angle, normal) * offset;
        points[i] = center + rotatedOffset;

        angle += 360f / n;
    }

    return points;
}

Set normal so that it's perpendicular to the circle you want to draw on. So if your game is 2D, use Vector3.forward, since that's perpendicular to the XY plane.

However, for a 2D game or one where every circle is on the same (axis-aligned) plane, I would just go with a trigonometric solution.

\$\endgroup\$

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.