Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

math.rad and the use in this scope? also, parameters?

Hi, I don't quite understand this. I'd like to modify it and use it for future projects, but I haven't seen CFrame done like this before.

For the most part, I understand it, but line 6 is a little confusing for me. I got this directly from the wiki article 'Circle', which I found here: http://wiki.roblox.com/index.php?title=Circle

My questions, if they can be answered: 1. Why do you have to get the radian of angle, can you replace that with a single number? 2. How does making the first parameter generate a circle?

I'm sorry if I'm a little vague about what I'm asking, but it seems so simple but I don't know what to do.

Thanks.

SCRIPT:

for angle = 1, 360 do
	local p = Instance.new('Part', Workspace)
	p.Size = Vector3.new(1, 1, 1)
	p.Anchored = true
	p.CFrame = CFrame.new(0, 120, 0)                --Start at the center of the circle
	         * CFrame.Angles(math.rad(angle), 0, 0) --Rotate the brick
	         * CFrame.new(0, 0, 100)                --Move it out by 100 units
	wait()
end

1 answer

✓ Accepted answer
  • You can replace it with a single number, but considering that you're making a circle, using a single number will be imprecise in terms of position, but will still generate a circle. That's because radians associate themselves with pi in terms of equal measure with degrees.

Since CFrame.Angles take units in radians, math.rad() accepts a number that's in degrees and converts it into radians. If the angle degree measure is 45, then you can just input math.pi/4 in place of math.rad(45), because they're equivalent.

Helpful link:

Unit Circle. You might learn this in high school.

  • Which parameter?

This discussion is preserved as it was. New answers, comments, and votes are closed.