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 / Sine, Cosine vs Linear Force

Author
Message
jeffhuys
20
Years of Service
User Offline
Joined: 24th May 2006
Location: No cheesy line here.
Posted: 24th Apr 2010 23:13
Hi,

I'm trying to throw a grenade with the following code:


As you see, I haven't figured out the XYZ values for the linear force. How could I find these? Probably using trig?
I know camera angles and position ofcourse

Thanks!

Jeff

Neuro Fuzzy
19
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 25th Apr 2010 05:53
basically, rotation matrices. Without getting into the math:

x#=cos(xrot)*cos(zrot)*sin(yrot)+sin(xrot)*sin(zrot)
y#=cos(xrot)*sin(zrot)*sin(yrot)-sin(xrot)*cos(zrot)
z#=cos(xrot)*cos(yrot)
ex:


You could also calculate everything using the matrix4 commands, and honestly it would probably a lot faster to do so... but I remember having lots of problems with those in the past. I think I posted a response to someone's thread that used matrix4s to do what you're doing, but it took me a while to figure it out.

Basically, what you see there is the result of this matrix:
http://www.freeimagehosting.net/uploads/3b4c8dfbe1.png
multiplied by
[0]
[0]
[1]

that big matrix though, it the result of the matrices of the Z rotation times Y rotation times X rotation. basically, where that 0,0,1 matrix = V,
[x]
[y] = Z*Y*X*V
[z]


Kira Vakaan
17
Years of Service
User Offline
Joined: 1st Dec 2008
Location: MI, United States
Posted: 25th Apr 2010 23:17
Here's an example using DBPro's matrices to get the position:


@Neuro Fuzzy:

Yeah, I hate DBPro's matrices. I figured them out a while back, but it took me a long time to do so. In this example, the angles I give for the rotation matrices must be specified in radians and not degrees (like everything else in the engine) for some completely unknown reason, and the multiply matrix4 command multiplies matrices in transformation order and not the logical, mathematically correct order. No clue why.

jeffhuys
20
Years of Service
User Offline
Joined: 24th May 2006
Location: No cheesy line here.
Posted: 26th Apr 2010 20:04
Hey, thank you both! I've got it working!

Neuro Fuzzy
19
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 28th Apr 2010 05:00
Quote: "multiplies matrices in transformation order and not the logical, mathematically correct order"


Aaaah yeah! I hate that! It's also annoying how "rotate x/y/z matrix4" constructs a new matrix, instead of multiplying

but oh well, it's still better than coding your own matrix stuff


Kira Vakaan
17
Years of Service
User Offline
Joined: 1st Dec 2008
Location: MI, United States
Posted: 28th Apr 2010 09:07
lol, I disagree, actually. I've already written a set of vector and matrix commands and after clocking them both, it turns out mine ran faster than DBPro's. I was very shocked at this.

Login to post a reply

Server time is: 2026-07-26 04:27:46
Your offset time is: 2026-07-26 04:27:46