Main Menu
  • Welcome to The RPG Maker Resource Kit.

A little help with circles.

Started by Tsunokiette, September 19, 2006, 11:13:06 PM

0 Members and 2 Guests are viewing this topic.

Tsunokiette

I know what Sine and Cosine are (mostly).

Sine = opposite / hypotonuse(sp?)
Cosine = adjacent /hypotonuse(sp?)

But since I have no clue how to apply that to circles, I used Seph's Ring Menu Customizable script as a reference.

Will the following have any chance of working as I hope it to? If it does, I'll use it for lots of stuff lol.

class Circle_Reference

def initialize(x,y,diameter)
@x = x
@y = y
@diameter = diameter
@radius = @diameter / 2
@circumference = (@diameter * Math::PI).floor
end

def find_point(percentage)
d1 = 2.0 * Math::PI / @circumference
d2 = d1 / @circumference
temp = @circumference * percentage.floor
for i in 0...@circumference
if i == temp
j = i - temp + 1
d = d1 * j + d2 * @steps
x = (@x + @radius) + ( @radius * Math.sin( d ) ).to_i
y = (@y + @radius) - ( @radius * Math.cos( d ) ).to_i
return [x,y]
end
end
end

end


EDIT : Let me rephrase this, how the heck do I do something like this? I just need to know the math portion, I'll figure the rest out. As I said before, all I need to know is how to find a point on a circle using Sine and Cosine.
"The wonderful thing about Tiggers
Is Tiggers are wonderful things
Their tops are made out of rubber
Their bottoms are made out of springs

They're bouncy, trouncy, flouncy, pouncy
Fun, fun, fun, fun, fun!
But the most wonderful thing about Tiggers
Is I'm the only one, I'm the only one."

Blizzard

#1
r - radius
x - coordinate on the x-axis
y - coordinate on the y-axis
fi - angle (in radians)

x = r * Math.cos(fi)
y = r * Math.sin(fi)

Don´t forget to set offset of the "zero-zero" point.
i.e. offset_x = offset_y = r

In that case you need to use something like

x_coord = offset_x - x
y_coord = offset_y - y
Get King of Booze for Android, for iOS, for OUYA or for Windows!
Visit our website.
You can also love/hate us on Facebook or the game itself.



Get DropBox, the best free file syncing service there is!

Tsunokiette

Thanks, I guess my problem now is understanding what Radians are. I've heard of them, but while I'm in the top percentile of my class, I don't know everything lol.

PS: Holy Cr*p, That's amazing. *refering to pm* Gah, having urge to finish highschool and go to college already.
"The wonderful thing about Tiggers
Is Tiggers are wonderful things
Their tops are made out of rubber
Their bottoms are made out of springs

They're bouncy, trouncy, flouncy, pouncy
Fun, fun, fun, fun, fun!
But the most wonderful thing about Tiggers
Is I'm the only one, I'm the only one."

Blizzard

I´m glad you like the file, lol.
Radians are similar to degrees. But instead of i.e. 180 degrees you have 1 * PI. 360 is 2 * PI, while i.e. 45 degrees is PI/4 in radians. It´s not REALLY complex, it just seems so.
Get King of Booze for Android, for iOS, for OUYA or for Windows!
Visit our website.
You can also love/hate us on Facebook or the game itself.



Get DropBox, the best free file syncing service there is!