Welcome, Guest. Please login or register.

Author Topic: Trigonometry Question  (Read 3859 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline NickTopic starter

  • Hero Member
  • *****
  • Join Date: Mar 2002
  • Posts: 1189
    • Show only replies by Nick
Trigonometry Question
« on: May 18, 2008, 07:57:42 PM »
Hello people. Just wondering how you find out the co-ordinates of a point on a circle. I've not needed to know this for a while, so i've forgotten how to do it. All examples of when I last did it have gone for some reason. I've almost got it, but its driving me mad! Its not quite working properly.

Thanks
Nick
 

Offline Cymric

  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 1031
    • Show only replies by Cymric
Re: Trigonometry Question
« Reply #1 on: May 18, 2008, 08:00:33 PM »
It's fairly simple trig, but what do you supply as input?
Some people say that cats are sneaky, evil and cruel. True, and they have many other fine qualities as well.
 

Offline NickTopic starter

  • Hero Member
  • *****
  • Join Date: Mar 2002
  • Posts: 1189
    • Show only replies by Nick
Re: Trigonometry Question
« Reply #2 on: May 18, 2008, 08:05:48 PM »
Yeah it isn't that difficult. I've got it to a point, but its just not right.

I have the X,Y of the centre of the circle
Radius of the circle
The angle is currently in degrees
 

Offline Cymric

  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 1031
    • Show only replies by Cymric
Re: Trigonometry Question
« Reply #3 on: May 18, 2008, 08:52:17 PM »
Ok. For a unit circle located on the origin, the coordinates of point P are simply (assuming that cos() and sin() take radians instead of degrees):

   P_x = cos(angle * \pi / 180)
   P_y = sin(angle * \pi / 180)

The radius of the circle is now R, and the origin is at (O_x, O_y), meaning that point P now resides at

   P_x = O_x + R * cos(...)
   P_y = O_y + R * sin(...)

If cos() and sin() take degrees, you can omit the \pi * 180 correction factor. Good luck!

Some people say that cats are sneaky, evil and cruel. True, and they have many other fine qualities as well.
 

Offline NickTopic starter

  • Hero Member
  • *****
  • Join Date: Mar 2002
  • Posts: 1189
    • Show only replies by Nick
Re: Trigonometry Question
« Reply #4 on: May 24, 2008, 01:39:59 PM »
Thanks for this. Sorry I forgot to thank you. As I got distracted my my game actually work! :)
 

Offline NickTopic starter

  • Hero Member
  • *****
  • Join Date: Mar 2002
  • Posts: 1189
    • Show only replies by Nick
Re: Trigonometry Question
« Reply #5 on: May 24, 2008, 08:37:07 PM »
I've just realised I need some more help with this. As I'm working in 3D, how do I workout a point on a sphere properly? I can work it out to a point, but it still doesn't work properly! I'm going to go crazy soon.
 

Offline Cymric

  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 1031
    • Show only replies by Cymric
Re: Trigonometry Question
« Reply #6 on: May 24, 2008, 09:44:55 PM »
Well, a sphere is something else again. You need 3 coordinates to locate a point on a sphere: two are angles, and one is a distance. The first angle is to indicate how far you should rotate in the plane going through the center of the sphere. Think of an orange you slice in two, and then trace the outer rim of one half. The other angle indicates how much up or down you should go---on the orange, once you've selected a point on the rim, trace from there to the  top (or bottom) of the fruit following the outer surface. The distance then simply moves a specified amount outward.

Assuming that the first angle is called \alpha and the second \beta, with distance R, then your formulas will then become:

P_x = O_x + R * cos(\alpha) * sin(\beta)
P_y = O_y + R * sin(\alpha) * sin(\beta)
P_z = O_z + R * cos(\beta)

Keep in mind that the definition of \beta is a little awkward: 0 degrees is straight up; 180 degrees is straight down. If you prefer to go with he more familiar 90 degrees straight up and -90 degrees straight down (note the minus!) then you should calculate

\beta_0_to_180 = 90 - \beta_90_to_90

first before inserting \beta_0_to_180 straight into the above equations. 3D geometry is a lot more complex than 2D geometry, as you can see.
Some people say that cats are sneaky, evil and cruel. True, and they have many other fine qualities as well.
 

Offline NickTopic starter

  • Hero Member
  • *****
  • Join Date: Mar 2002
  • Posts: 1189
    • Show only replies by Nick
Re: Trigonometry Question
« Reply #7 on: May 24, 2008, 11:28:13 PM »
Thanks. This is going to take some figuring out. I'm using this to work out the thrust angles in my space game. The difficult part is making it so it only gives angles between 0 and 180 and allow the ship to rotate on all axis. I'm also using this to workout where the nose is pointing, and the trajectory. It works in 2D at the moment, but the second you go into the 3rd dimension things go all 5th dimension :) All the angles go crazy. I'll probably spend half of tomorrow using this!
 

Offline NickTopic starter

  • Hero Member
  • *****
  • Join Date: Mar 2002
  • Posts: 1189
    • Show only replies by Nick
Re: Trigonometry Question
« Reply #8 on: May 26, 2008, 02:00:29 PM »
This is getting annoying now. Basically I'm making a 3D space game. I'm new to 3D programming. I want to make my spacecraft be able to rotate on all axis (which is simple) and be able to fire thrusters in any direction (on all axis). Its this problem which is halting my project. I've got it to partially work, but it just won't go in the direction the thrusters are facing. Do you have any thoughts? You seem better at maths than me! Once I've got my head around this I'll be happy!

Nick
 

Offline bloodline

  • Master Sock Abuser
  • Hero Member
  • *****
  • Join Date: Mar 2002
  • Posts: 12113
    • Show only replies by bloodline
    • http://www.troubled-mind.com
Re: Trigonometry Question
« Reply #9 on: May 26, 2008, 02:23:17 PM »
Quote

Nick wrote:
This is getting annoying now. Basically I'm making a 3D space game. I'm new to 3D programming. I want to make my spacecraft be able to rotate on all axis (which is simple) and be able to fire thrusters in any direction (on all axis). Its this problem which is halting my project. I've got it to partially work, but it just won't go in the direction the thrusters are facing. Do you have any thoughts? You seem better at maths than me! Once I've got my head around this I'll be happy!

Nick


This sounds like you haven't got your plan sorted out...

Are you able to give more details about the the 3D engine you are using?

Offline NickTopic starter

  • Hero Member
  • *****
  • Join Date: Mar 2002
  • Posts: 1189
    • Show only replies by Nick
Re: Trigonometry Question
« Reply #10 on: May 26, 2008, 02:47:26 PM »
I had planned it (this part of it), but as I'm only learning it didn't work. This is basically a test version of the game. Once I've got this figured out I'm planing on starting from scratch, using the knowledge gained to start properly. I'm using DarkBASIC. Its not bad actually. I'm impressed at how easy it is to get stuff working....unless it's complicated maths. Theres not much you can do about that!
 

Offline bloodline

  • Master Sock Abuser
  • Hero Member
  • *****
  • Join Date: Mar 2002
  • Posts: 12113
    • Show only replies by bloodline
    • http://www.troubled-mind.com
Re: Trigonometry Question
« Reply #11 on: May 26, 2008, 03:11:42 PM »
Quote

Nick wrote:
I had planned it (this part of it), but as I'm only learning it didn't work. This is basically a test version of the game. Once I've got this figured out I'm planing on starting from scratch, using the knowledge gained to start properly. I'm using DarkBASIC. Its not bad actually. I'm impressed at how easy it is to get stuff working....unless it's complicated maths. Theres not much you can do about that!


I get it, this is the exploratory run... Ok... but I'm still keen to know more about your 3D engine...

Offline NickTopic starter

  • Hero Member
  • *****
  • Join Date: Mar 2002
  • Posts: 1189
    • Show only replies by Nick
Re: Trigonometry Question
« Reply #12 on: May 26, 2008, 03:26:20 PM »
 

Offline bloodline

  • Master Sock Abuser
  • Hero Member
  • *****
  • Join Date: Mar 2002
  • Posts: 12113
    • Show only replies by bloodline
    • http://www.troubled-mind.com
Re: Trigonometry Question
« Reply #13 on: May 26, 2008, 03:37:08 PM »
Quote

Nick wrote:
The 3D engine is at http://darkbasicpro.thegamecreators.com/


Hmmm... doesn't that provide a set of functions for keeping track of your objects and thair properties... is DarkBASIC object oriented?

Offline NickTopic starter

  • Hero Member
  • *****
  • Join Date: Mar 2002
  • Posts: 1189
    • Show only replies by Nick
Re: Trigonometry Question
« Reply #14 on: May 26, 2008, 03:57:58 PM »
No its not object orientated. Its just like BASIC except simple commands load and move objects around etc. It can keep track of objects. The move commands I have (you can get extra plugins) won't do exactly what I want, so I'm trying to get around them. Its an easy programming language. Within my second day of using it I had made a simple 3D landscape using a displacement map (which was grabbed from a small bitmap I made). A simple 3D object was driveable with the camera following it. It also drove over the landscape properly, well except I didn't even start the problem of it not rolling on the hills, it only pitched up n down. It was a good start I think. No help was needed on that one! Its just this mathematical problem has got me. I've been wanting to make this game for like 10 years! :-)