-2

I am using c# but I am hoping the mathematics SO is a better place for this question. I have a point (x, y, z) and I am looking to create x (pointCount) number of points around it like a hula hoop. What I have so far circles around vertically above and below the point and not around it.

float centerX = transform.position.x;
float centerY = transform.position.y;
float centerZ = transform.position.z;

// Get the rotation of the character in degrees float rotation = transform.rotation.eulerAngles.y;

// Loop through each angle and calculate the x and y coordinates of the point at that angle for (float angle = 0; angle < 360; angle += 360.0f / pointCount) { //angle will equal e.g. 30, 60, 90, 120 .... etc float x = centerX + distance * Mathf.Sin((angle + rotation) * Mathf.Deg2Rad); float y = centerY + distance * Mathf.Cos((angle + rotation) * Mathf.Deg2Rad); float z = centerZ + 1.0f * Mathf.Clamp(Mathf.Sin(angle * Mathf.Deg2Rad), -1.0f, 1.0f);

    // Create a Vector3 object for the point and add it to the list
    Vector3 point = new Vector3(x, y, z);
    points.Add(point);

}

I can't seem to modify this to be around and not over the point.

  • 1
    It is quite unclear what you are trying to do. In 3D there is an infinitude of circles around a point. In which plane you want yours? Perhaps in z=0? – Kurt G. Jan 04 '23 at 07:49
  • I think the correct term is around the Y axis. – SamohtVII Jan 04 '23 at 08:01
  • The points on a circle around $(x,y,z)$ that goes around the $y$-axis all have the same $y.$ Your program changes $y$. Looks wrong. – Kurt G. Jan 04 '23 at 08:16

1 Answers1

2

$\{x + \cos \theta, y, z + \sin \theta \}$

where $\theta = 0, 2 \pi/n, 4 \pi/n, 6 \pi/n, \ldots$