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.

Dark GDK / using trigonometry to rotate 3d model

Author
Message
iammfa
15
Years of Service
User Offline
Joined: 14th Feb 2009
Location:
Posted: 18th Nov 2009 13:07 Edited at: 18th Nov 2009 13:10
Hello everyone,
The practice which i'm working in, aim to using trigonometry to rotate 3d model with mouse, i almost finished all source code to achieve this task, although that, the model still not rotate, i hope someone tell me where is my mistake:
this is my code

old man
20
Years of Service
User Offline
Joined: 25th Feb 2004
Location:
Posted: 21st Nov 2009 15:30
Hello iammfa

Not about to do your homework for you, and not too sure of what you are trying to do.

But.. think about the axes that you are dealing with, X is easy because it is a cross, Y goes up and down, Z is in and out.

Also think about using negative numbers in Pythag, indeterminate results unless you check + and - results.

Good luck.

uff
Caleb1994
15
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 21st Nov 2009 21:46 Edited at: 21st Nov 2009 21:47
Quote: " nAngle = dbSin (nDis/nDis02);

"


There's your problem. Atleast that's what it looks like. The formula to get the angle is:

atan(opposite/adjacent)

where opposite is the length of the side opposite the angle and adjacent is the well length of the side adjacent to the angle, but atan only returns 0-90 it doesn't tell you which of the four 90 degree sectors it's in. to do that use:

atan2(opposite, adjacent)


note. You need to include cmath to use these functions. DarkGDK Has them:

dbAtan(opposite/adjacent)

and

dbAtanFull(adjacent,opposite)

as you can see dbc's version of atan2(atanfull) takes the adjacent side first not the opposite.

It looks like you had the right idea, just using the wrong function(Sin instead of atan)

Oh you want to use wrapvalue with atan2 or atanfull as they return -180 to 180.

New Site! Check it out \/

Login to post a reply

Server time is: 2024-10-01 18:38:11
Your offset time is: 2024-10-01 18:38:11