Posts: 442
Threads: 107
Joined: Feb 2005
geez, i'm having so much trouble understanding this, i've looked at tutorials, and the like..but none of them seem to be very clear... here's a pic
now, lets say we want a pixel that moves in a circle around the screen.. would the pixel "ride" on Q? and how does R's value change where Q is going??? my head hurts...
url=http://www.random-seed.net]
[/url]
Posts: 1,439
Threads: 15
Joined: Apr 2003
If you're using radians for the angle measurement (you should, since that's what sine and cosine implementations on a computer use), then x (the angle) ranges from 0 to 2 * pi.
Code:
option explicit
const pi as single = 3.141592654
dim angle as single
dim center_x as integer, center_y as integer
dim radius as integer
radius = 90 ' radius of the circle (distance from center to any point on the circle)
center_x = 320 \ 2 ' center of circle
center_y = 200 \ 2
screen 13
for angle = 0 to (2 * pi) step (pi / 256)
pset ( center_x + cos(angle) * radius, _
center_y + sin(angle) * radius ), 15
sleep 10
next angle
do while len(inkey) = 0
loop
Posts: 442
Threads: 107
Joined: Feb 2005
um..ok, here's a question
1.is cos the distance between "R" and "O" ?
2.is sin the distance between "R" and "Q" ?
url=http://www.random-seed.net]
[/url]
Posts: 2,404
Threads: 153
Joined: Jan 2005
Yes, Sin is for Y, Cos is for X
H = your hypotinuse, or in this case, the radius of you circular pattern.. but since where going for intended circular pattern to a X Y cord on the screen, think of it as the hypotinuse..
Sin is for Y, So, for it to become the distance we use..
Sin (Angle) = O/H
If you had O, the distance between "R" & "Q", and divided it by H (Which in your diagram equals 1) you'd get the Sin of the angle, in turn that can give you the angle.. This can be reversed tho so if you have the angle:
O = H * SIN (angle)
Now O = Distance from "R" & "Q" then subtracting that from the center of your screen will give you the Y cord..
Y = O - ScreenCenterY
Same for X except you add the screen center..
A = H * COS (angle)
X = A + ScreenCenterX
And you most convert Degrees to Radians for this to work in a program:
angleR = angle * 3.14 / 180
Then
O = H * SIN (angleR)
Y = O - ScreenCenterY
A = H * COS (angleR)
X = A + ScreenCenterX
And this is just a overview, its a litte more to 2D and 3D.. :wink:
Kevin (
x.t.r.GRAPHICS)
Posts: 1,057
Threads: 156
Joined: Aug 2003
Posts: 442
Threads: 107
Joined: Feb 2005
hey, thnx, that diagram helps quite a bit.. i got a question tho.. whats the little symbol that looks like a zero? but, not quite like a zero, more like a helecopter landing pad?
url=http://www.random-seed.net]
[/url]
Posts: 1,439
Threads: 15
Joined: Apr 2003
Greek letter uppercase theta
Posts: 1,057
Threads: 156
Joined: Aug 2003
Posts: 2,404
Threads: 153
Joined: Jan 2005
Heh, a Tranverse wave Sin diagram, you just throw that in for the heck of it, he's trying 3D rotations, not drafting sound waves... :wink: oh well, :roll: ...
Kevin (
x.t.r.GRAPHICS)
Posts: 292
Threads: 31
Joined: Apr 2003
Those diagrams are good and all, but do yourself a favor and get used to radians. It will make your life much easier in more advanced math classes.