Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
sin and cos help
#1
uh, yeah, i'm trying to figure out how sin and cos work.. i was trying to make a circle move on the screen in a circle..but failed horribly
url=http://www.random-seed.net][Image: asylumsig.png][/url]
Reply
#2
I'll try to explain:
Look up trigonometry in a math book for a better explanation.

....................Q
................../|
................/..|
............../....|
.....a...../......|
........../........| b
......../..........|
....../............|
..../_______|
P.........c

The angle alpha is the angle between the sides a and c
the angle between the sides b and c is 90 degrees

sin(alpha)=b/a
cos(alpha)=c/a

a*sin(alpha)=b
a*cos(alpha)=c

that means if point P is at the coordinates (0;0)
Point Q will be at the coordinates(a*cos(alpha);a*sin(alpha))
/post]
Reply
#3
um...that helps a little i guess..
url=http://www.random-seed.net][Image: asylumsig.png][/url]
Reply
#4
mybe somthing like this will help


Y = Sin(ang )*M
X = Cos(ang)*M

M would be the magnatued of the vector

oh ya i think freebasic use's rad's for it sin , cos and tan function so you will have to convert degree's to rad which is

ang in degreas * (Pi/180)
Reply
#5
Try This:

Code:
const PI as double  = 3.1415926535897932385
const CircleRadius as double = 9.5

dim angle as double
dim x as double
dim y as double
dim old_x as double
dim old_y as double


screen 18,32,1,1
window screen (-10,10) - (10,-10)
cls
PRINT "Hit Any Key To Begin"
sleep

'Draw some old fashioned X, Y axis
line (-10,0)-(10,0),rgb(255,0,0)
line (0,10)-(0,-10),rgb(255,0,0)

'clear out the key buffer
do while inkey$<>""
loop

for angle = 0 to 2*pi step Pi/12
      pset(old_x,old_y),rgb(0,0,0)
      x = CircleRadius * cos(angle)
      y = CircleRadius * sin(angle)
      pset (x,y),rgb(255,255,255)
      old_x = x
      old_y = y
      sleep 500
next angle


sleep

What exactly are you having problems with? The graphics? The trig? The Radians?
Reply
#6
The best thing you can do, if you really want to understand what's going on, is Google for 2D rotation tutorials...

Here's one for QB, written by by Toshie Horie. It's got everything you need to know, plus a bunch of stuff that's great to know for making games. Wink

http://www.ocf.berkeley.edu/~horie/qbrotate.html
Reply
#7
trig and radians... and how it all worx
url=http://www.random-seed.net][Image: asylumsig.png][/url]
Reply
#8
A good trig book is all you'll ever need to understand them sine's. :*)
y smiley is 24 bit.
[Image: anya2.jpg]

Genso's Junkyard:
http://rel.betterwebber.com/
Reply
#9
Maths are taught at school Tongue Trig is taught when pupils are 13 or 14, I think.
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Reply
#10
OMFG!!! i'm actually starting to get it!!! :bounce:

Code:
screen 13

dim x as integer
dim y as integer
dim xval as integer
dim yval as integer
dim xpos as integer
dim ypos as integer
dim angle as double

xval = 160
yval = 100
x = 25
y = 25

do
   angle = angle + .01
xpos = x * sin(angle) + y * cos(angle)
ypos = y * sin(angle) - y * cos(angle)

circle (xval + xpos, yval + ypos),15,4
sleep 10
cls
loop

btw, i'm a highschool dropout, and they didnt teach sin, cos, during the time i was in school
url=http://www.random-seed.net][Image: asylumsig.png][/url]
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)