Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Need help with Trignometry functions

Author
Message
Neotron
16
Years of Service
User Offline
Joined: 21st Jul 2010
Location: I am in an underworld , making a E.Army
Posted: 21st Jul 2010 21:38
Hi all,

i have been trying to make universal function program (in dbpro) which will be ofcourse free of charge!!

but i have some problems too ideas.

i have been coding to make an object go around another's local axis.
so far i have done these functions:-


X and Z functions are working good but having some problem over the Y axis as it just go up and down but not in a circle any

ALLAH IS THE GREATEST
May he forgive me
Hawkblood
16
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 21st Jul 2010 22:25
Do you just want an object to orbit in a specific orbital pattern?

The fastest code is the code never written.
The Wilderbeast
20
Years of Service
User Offline
Joined: 14th Nov 2005
Location: UK
Posted: 21st Jul 2010 22:51


Should work fine, in fact I'll just test it now...

Hawkblood
16
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 21st Jul 2010 22:54
@The Wilderbeast I think Neotron was wanting to move in all 3 diminsions. Your example keeps Y=0.

The fastest code is the code never written.
Neotron
16
Years of Service
User Offline
Joined: 21st Jul 2010
Location: I am in an underworld , making a E.Army
Posted: 21st Jul 2010 22:57
Thanks for the reply Hawkblood

but no , i think it should be like TFORM function from blitz3d.

these xyz functions should force the object to be positioned in the first object local axis just like a parent child function exept it returns values.
e.g.
l o
-> o l ^
l l
->=parent , o=child

ALLAH IS THE GREATEST
May he forgive me
The Wilderbeast
20
Years of Service
User Offline
Joined: 14th Nov 2005
Location: UK
Posted: 21st Jul 2010 23:09
Well I have provided three functions (x, y, z). The example code was merely a demonstration. If you are resourceful, you could quite easily get it to work in all 3 axis.

Neuro Fuzzy
19
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 26th Jul 2010 23:13 Edited at: 26th Jul 2010 23:14
Ah, I see what the problem is...

@ the wilderbeast
unless I'm mistaken... Those functions don't really help at all for 3d rotation and roll.


Basically, DBPro uses euler rotation matrices, which are a pain to deal with. Not so basically, this:

It's a matrix composed of rotation around the x axis, then y axis, then z axis. Really, it's only that complicated when you multiply everything out (kind of like, you can say (a+b)^24 or have a massive equation), but that form is simpler if you want to convert to regular trigonometry functions.

With the built in dbpro commands, I believe you can grab an object's rotation matrix, and then apply that to a position vector. I'll look into how once I get back, cuz i have to leave mah comp in like 3 mins.

[edit]
but yeah, dealing in-depth with rotation isn't for the math-shy; you can however get EZ rotate, which I've heard is great.


Is't life, I ask, is't even prudence, to bore thyself and bore thy students?
Hawkblood
16
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 27th Jul 2010 16:40
Are you trying to make something orbit another??? Like a moon or satellite? What orbital type do you want?

The fastest code is the code never written.
Neotron
16
Years of Service
User Offline
Joined: 21st Jul 2010
Location: I am in an underworld , making a E.Army
Posted: 27th Jul 2010 18:20
hawkblood i just want the objects local axis coordinates in a type of radius.

e.g. objx=2
objy=2
objz=3

in globalx=objx + localx(adding value)


like a rod having two balls on ends . when one ball rotates the other orbits it. i want the orbiting balls axis.

thanks

ALLAH IS THE GREATEST
May he forgive me
Hawkblood
16
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 27th Jul 2010 21:51
Normally when you say "local" it refers to the lowest frame of reference. I think you are wanting to say:
moon orbits planet.
what is moon's x, y, and z axis
right?

The fastest code is the code never written.
Scraggle
Moderator
23
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 27th Jul 2010 23:14 Edited at: 28th Jul 2010 00:05
The easiest way to have one object orbit another is to use spherical co-ordinates instead of the usual cartesian.
Once the spherical co-ordinates are determined it is a simple task to convert them back to cartesian.

I have created this small bit of code that demonstrates a planet orbiting a sun and a moon orbit that planet.



[Edited for clarity]



Neotron
16
Years of Service
User Offline
Joined: 21st Jul 2010
Location: I am in an underworld , making a E.Army
Posted: 28th Jul 2010 19:57
scraggle thnx for the code but try and apply it to a 3rd person camera , the camera

and also the function must return seperate values

thnx!!!!!

ALLAH IS THE GREATEST
May he forgive me
Scraggle
Moderator
23
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 28th Jul 2010 20:30
You never said anything about 3rd person cameras.
You asked for an object to rotate about another and that is exactly what my code does!



Neotron
16
Years of Service
User Offline
Joined: 21st Jul 2010
Location: I am in an underworld , making a E.Army
Posted: 28th Jul 2010 20:57
yeah but i actually wanted a camera to move into a rolling spaceship axises.

ALLAH IS THE GREATEST
May he forgive me
Neotron
16
Years of Service
User Offline
Joined: 21st Jul 2010
Location: I am in an underworld , making a E.Army
Posted: 15th Aug 2010 13:43
Quote: "
Normally when you say "local" it refers to the lowest frame of reference. I think you are wanting to say:
moon orbits planet.
what is moon's x, y, and z axis
right?
"


yeah same thing but with "moon's x,y,z global axis according to earths local axis e.g. ( x=3,y=4,z=2)

thnx.

ALLAH IS THE GREATEST
May he forgive me
Kira Vakaan
17
Years of Service
User Offline
Joined: 1st Dec 2008
Location: MI, United States
Posted: 16th Aug 2010 09:18
Alright, so if the universe has a center, the earth has a center, and the moon has a center, you want to represent the moon's orientation in relation to the earth's? I dunno what you're saying about (x=3, y=4, z=1)...

Well assuming you have the moon's orientation in relation to the universe (world space), and the earth's orientation in relation to the universe (also world space), you'd just need to multiply the moon's world matrix by the inverse of the earth's world matrix.

In a transform matrix, the first three columns are the axes of the coordinate space (in the order: X, Y, Z).

Neuro Fuzzy
19
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 16th Aug 2010 09:21
Quote: "yeah but i actually wanted a camera to move into a rolling spaceship axises."



by "thnx" do you mean you've solved it or that you still need help?
I learned a bunch more on local rotation so I can actually telly oyu something useful xD


Is't life, I ask, is't even prudence, to bore thyself and bore thy students?
Hawkblood
16
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 16th Aug 2010 18:06
I think you are trying to figure it out for yourself (and that's good), but you may be asking the wrong question..... What is the final product going to do? Is there going to be a player on a moon that's orbiting a planet and you need to have the camera ultimately local to the player?

The fastest code is the code never written.
Neotron
16
Years of Service
User Offline
Joined: 21st Jul 2010
Location: I am in an underworld , making a E.Army
Posted: 16th Aug 2010 21:43
kira vikaan , you have got the point but i dont know much about vectors or matrices ( all i know they were in my last year college maths which was math based not computer based i think)

and i didnt solve the problem neuro , but i would really need help.

alright let me get this straight for all ya . in the game named "Spyro the dragon" a dragonfly follows him with respect to its orientation (spyro).

so i need the x,y,z euler coordinates in order to make an object follow the required coord .

ok a little simple a camera behind a spaceship rotating in all directions . i need a formula to calculate the camera coordinates
my first attempt got x and z right but y is the main problem.

again thnx ( for reply)

ALLAH IS THE GREATEST
May he forgive me
Neotron
16
Years of Service
User Offline
Joined: 21st Jul 2010
Location: I am in an underworld , making a E.Army
Posted: 16th Aug 2010 21:45
and can some one guide me to 3d maths tutorial. i think its really helpful.

ALLAH IS THE GREATEST
May he forgive me
Kira Vakaan
17
Years of Service
User Offline
Joined: 1st Dec 2008
Location: MI, United States
Posted: 17th Aug 2010 08:37
I see, well unless you write your own set of functions to handle vector and matrix operations (which, after you do some studying, isn't hard and I strongly recommend doing, as the native DBPro vector and matrix commands suck), you're stuck using the convoluted DBPro vector and matrix commands.

But before you worry about that, I found this set of tutorials that looks pretty good. It was the first result of a "vector and matrix tutorial" google search.

What you'll need to do after you learn about vectors and matrices is basically to build the "moon's" world matrix (by multiplying together three rotation matrices, one scale matrix, and one translation matrix) along with the "earth's" world matrix, then invert the earth's world matrix to get the inverse world matrix, and finally multiply the moon's world matrix by the earth's inverted world matrix. The resulting matrix will transform vectors around the earth.

However, if you already have the coordinates (in relation to the earth) of the object you want to position around the earth, wherever that may be in the universe, you'll just need to apply the earth's world matrix to get their position in relation to the universe (the world).

Neotron
16
Years of Service
User Offline
Joined: 21st Jul 2010
Location: I am in an underworld , making a E.Army
Posted: 17th Aug 2010 15:57
kira vakaan thnx for the tut (i tried tons of time but couldn't find it myself )

alright i'll get my problem solved by a teacher or rather to solve it myself

thnx for posting

ALLAH IS THE GREATEST
May he forgive me

Login to post a reply

Server time is: 2026-07-24 20:35:12
Your offset time is: 2026-07-24 20:35:12