- Home /
Question by
itscoolbro · Sep 20, 2013 at 08:00 PM ·
mathfcircleradiuscos
radiusX and radiusY ?
I took the code below from this question: http://answers.unity3d.com/questions/28215/instantiate-prefabs-in-a-circle-or-elipsoid.html
var numPoints = 20;
var centrePos = Vector3(0,0,32);
for (var pointNum = 0; pointNum < numPoints; pointNum++)
{
// "i" now represents the progress around the circle from 0-1
// we multiply by 1.0 to ensure we get a fraction as a result.
var i = (pointNum * 1.0) / numPoints;
// get the angle for this step (in radians, not degrees)
var angle = i * Mathf.PI * 2;
// the X & Y position for this angle are calculated using Sin & Cos
var x = Mathf.Sin(angle) * radiusX;
var y = Mathf.Cos(angle) * radiusY;
var pos = Vector3(x, y, 0) + centrePos;
// no need to assign the instance to a variable unless you're using it afterwards:
Instantiate (beadPrefab, pos, Quaternion.identity);
}
However, I don't understand what radiusX and radiusY represent. If someone could clear it up for me I would appreciate it.
Comment
Best Answer
Answer by vbbartlett · Sep 20, 2013 at 08:05 PM
radiusX and radiusY are the radius of the "circle" in each of those axis. If they are equal then you will get a circle, if they are not, you will get an ellipse
Your answer
Follow this Question
Related Questions
Unity3d how to make cos 90 equal to 0? 1 Answer
Limit Mouse Look to Circle 1 Answer
Spawn prefabs in a circle? 3 Answers
Cos creates problems with addforce 0 Answers