vbGore Free Online RPG Engine

Revolutionizing Visual Basic ORPG Development
It is currently Wed May 22, 2013 2:32 am

All times are UTC - 8 hours




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: Radians
PostPosted: Mon Jul 20, 2009 3:47 pm 
Slave to the BB

Joined: Sat May 12, 2007 6:20 am
Posts: 3842
Location: Behind you!
So, I was messing with XNA and found the MathHelper.Clamp method to be useful. But when I put in
Code:
MathHelper.Clamp(some.object, 180, 0);

it didn't work. I looked it up on MSDN and found that it uses radians and not degrees. So, what my question is what use are they? Basically its just another way to say degrees.

Image


Top
 Profile  
 
 Post subject: Re: Radians
PostPosted: Mon Jul 20, 2009 8:09 pm 
Illegal Operation

Joined: Sun Jun 07, 2009 3:09 pm
Posts: 417
Location: poririn-poriri-pori-pororocca
Radians are easier to use than degrees when doing certain types of math or drawing graphs, its just like the difference between using fractions and decimals.


Top
 Profile  
 
 Post subject: Re: Radians
PostPosted: Mon Jul 20, 2009 8:11 pm 
Slave to the BB

Joined: Sat May 12, 2007 6:20 am
Posts: 3842
Location: Behind you!
Code:
                        Vector2(
                        (float)Math.Cos(someobject.rotation),
                        (float)Math.Sin(someobject.rotation) * 5.0f);


So, someobject has its rotation stored as a radian how in the hell would this make it move... not to mention it makes the objects move poorly based off the rotation of someobject. If you aim straight up or at 0 degrees the angle is fine but anywhere in between the angle is off.


Top
 Profile  
 
 Post subject: Re: Radians
PostPosted: Mon Jul 20, 2009 8:59 pm 
Site Admin

Joined: Fri Jul 14, 2006 4:00 pm
Posts: 11230
Location: Washington
Radians are useful in trig/calc/physics. Essentially, instead of having a range of 0 to 360, you have a range of 0 to 2pi. Its a very simple difference, but very useful to have it as a radian instead in most cases.

As for your second post, I don't really understand it.


Top
 Profile  
 
 Post subject: Re: Radians
PostPosted: Tue Jul 21, 2009 12:01 am 
Slave to the BB

Joined: Sat May 12, 2007 6:20 am
Posts: 3842
Location: Behind you!
Yeah, I fixed the second part its just that I don't get how it works. Mainly because I've never used or seen (float) in front of something before I'm assuming it converts the value to a float but I could be wrong. And geometry sin/cos/tan was the only test I failed when I took geometry.


Top
 Profile  
 
 Post subject: Re: Radians
PostPosted: Tue Jul 21, 2009 1:59 am 
Illegal Operation

Joined: Sun Jun 07, 2009 3:09 pm
Posts: 417
Location: poririn-poriri-pori-pororocca
The thing in the brackets before the expression is a type cast. You can type cast any number with another number and interfaces or child/ancestor classes, you can think of it simply as converting from one type to another. It's actually quite simple how it works if you understand lower level OOP.

In your case its probably a double to a float.

If you don't want to use sin or cos, you can use a rotation matrix. However its hard to understand and easy to forget, but once you know it, it becomes much easier than trig, its also a lot faster (brain and cpu wise) if you don't need exact calculations, even better if you understand magic numbers like sqrt3/2 as its based on the unit circle.

As for the Vector2D i think you need to do a bit of research on trig. If the parameter requires radians then you will have to divide the rotation by 180 before you use it as an argument (unless the rotation is also in radians). Also as sin is the vertical component, of course the angle is going to be off if it the point is 5 times higher than it is to the left or right.

Spodi wrote:
Its a very simple difference, but very useful to have it as a radian instead in most cases.


If by that you mean for rendering such as NotExistants Vector2D im not sure how that could possibly be. Both OpenGL and DX8 use floating-point degrees and 3 rotation matrices, i dunno about the other DX's as i haven't tried. If not then meh i dunno, its only been useful when there isn't a calculator involved, which is why i don't think its particularly suitable for programming. :cry:


Top
 Profile  
 
 Post subject: Re: Radians
PostPosted: Tue Jul 21, 2009 8:35 am 
Slave to the BB

Joined: Sat May 12, 2007 6:20 am
Posts: 3842
Location: Behind you!
Code:
                        Vector2(
                        (float)Math.Cos(someobject.rotation),
                        (float)Math.Sin(someobject.rotation)) * 5.0f;

Yeah, that was the problem I needed to multiply the X and Y by 5 else the speed was messed up and the objects would go up faster. Oh, and the rotation is stored as a radian too. I actually went and looked up sine, cosine and tangent again and this time around it seemed pretty easy. The power of the internet lol it tough me things my teacher tried to explain to me a million times and it was pretty easy.

So in the end what this is really doing is taking the angle of the object and evaluating an imaginary triangle to see how high it is to get two of the sides and its using them to set the acceleration for another object to match the angle of the first object.

I still don't get it fully but I get what its doing to an extent now I may look at it a little longer to see exactly how it works but right now I understand the concept.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC - 8 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group