Qbasicnews.com

Full Version: rotating and moving 2D
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
ok, now im good with math.
but when it came to circles/degrees and trig
(or what ever this math problem falls under)
i must have been asleep in class.

lets say you have a point in space. its x=100, y=100
and you have rotated 67Degrees
now to drive or fly
(which ever the case for whom ever has the same question.)
what is the math to plot my new XY's till i put on the breaks?
woohoo! finally something that i can actually help on! usually i someone beats it to me or i have no idea what there on about Smile

the way i do it is thus:
Code:
' say i want to move my dot 10 steps in a 67 degree direction
x = 100 '  \____ original position
y = 100 '  /

angle = 67  'umm.. does this need explaing? ;)
step.length = 10 ' how far it will move in the disired direction

newx = x + (sin(67) * step) ' the new x position
newy = y + (sin(67) * step) ' the new y position
one of those sin's should be a cos
sin,cos and friends use RAD no DEGREES
Code:
x=cos(pi/180*degrees)*r + middlepointx
y=sin(pi/180*degrees)*r + middlepointy

Joshy
i have tryed looking it up!

but what is a rad?

why should you use rad over degrees

or is a rad a degree?

LOL rads are my wrench in the mix
if you know what i mean.
lol Radians is the complete name.

To work with angles, there's 3 means of representing them.

1. Degrees (what we all learned at school)
2. Radians (what we wished we learned in school lol)
3. Gradians (what we hope never to learn at school).

The fastest way for a computer to compute an angle is by using radians, it is also the best way to represent everyhing on a computer screen graphically. google for "math" "radians" and you'll find something quick and simple to learn from :-).

Hope this helps
ok ill try google
Just a couple quick math junkie tips:
180 degrees = 200 grads (full term is "gradians") = PI radians
360 degrees = 400 grads = 2*PI radians

Calculations:
DEG -> GRA: numDegrees * (10 / 9)
DEG -> RAD: numDegrees * (PI / 180)

RAD -> DEG: numRadians * (180 / PI)
RAD -> GRA: numRadians * (200 / PI)

GRA -> DEG: numGrads * (9 / 10)
GRA -> RAD: numGrads * (PI / 200)

Why do those calculations work? Well, I originally typed a HUGE (and poorly organized) explanation with examples, but let's just say Google can help more than I can. :lol:
ok ive done some work! i have a circle halfa$$'d moving around!
doing the bouncing of the wall thing!

LOL old school for you guys i bet!

ive mainly worked on tile engines they are my fav.

anyway!
does a grad have any purpose at all?
this is the first ive hurd of them!
Gradians I've heard from friends was used in mountain related calculations (like for slope calculations) and forestry as well...but that was a while ago. I haven't heard of a recent usage of it even in mountains and forestry they use standard geometry and trigonometry to evaluate these things now I believe.

I did a google research and some say gradians came from the french back when they thought breaking things in 10s and 100s was fun which is why a right angle in gradians is 100 degrees, not 90 ,, go figure ;-).
Pages: 1 2