Gamestudio Links
Zorro Links
Newest Posts
Newbie Questions
by fairtrader. 12/05/23 14:22
Zorro Trader GPT
by TipmyPip. 12/04/23 11:34
Square root rule
by Smallz. 12/02/23 09:15
RTest not found error
by TipmyPip. 12/01/23 21:43
neural function for Python to [Train]
by TipmyPip. 12/01/23 14:47
Xor Memory Problem.
by TipmyPip. 11/28/23 14:23
Training with command line parameters
by TipmyPip. 11/26/23 08:42
Combine USD & BTC Pairs In Asset Loop
by TipmyPip. 11/26/23 08:30
AUM Magazine
Latest Screens
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Who's Online Now
3 registered members (TedMar, AndrewAMD, fairtrader), 578 guests, and 0 spiders.
Key: Admin, Global Mod, Mod
Newest Members
fairtrader, hus, Vurtis, Harry5, KelvinC
19019 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
How does vec_to_angle work? #125450
04/21/07 13:59
04/21/07 13:59
Joined: Jan 2007
Posts: 1,619
Germany
Scorpion Offline OP
Serious User
Scorpion  Offline OP
Serious User

Joined: Jan 2007
Posts: 1,619
Germany
I tried for hours to find out how vec_to_angle could work...but no results, does someone of you know it?

edit: i mean not how to use it... i mean what this function does

Last edited by Scorpion; 04/21/07 14:00.
Re: How does vec_to_angle work? [Re: Scorpion] #125451
04/21/07 14:11
04/21/07 14:11
Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
tompo Offline
User
tompo  Offline
User

Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
??!!

Last edited by tompo; 04/21/07 14:12.

Never say never.
Re: How does vec_to_angle work? [Re: tompo] #125452
04/21/07 15:08
04/21/07 15:08
Joined: Jan 2007
Posts: 1,619
Germany
Scorpion Offline OP
Serious User
Scorpion  Offline OP
Serious User

Joined: Jan 2007
Posts: 1,619
Germany
lol i mean...how was it programmmed...how can i "rebuild" it in c-script..etc

Re: How does vec_to_angle work? [Re: Scorpion] #125453
04/21/07 15:38
04/21/07 15:38
Joined: Jul 2006
Posts: 503
Australia
A
adoado Offline

User
adoado  Offline

User
A

Joined: Jul 2006
Posts: 503
Australia
I searched the net a little and found this:

http://nuttybar.drama.uga.edu/pipermail/dir3d-l/2002-September/000397.html

Not sure if it is of any help - hopefully it is

Goodluck,
Adoado


Visit our development blog: http://yellloh.com
Re: How does vec_to_angle work? [Re: adoado] #125454
04/21/07 16:25
04/21/07 16:25
Joined: Jan 2007
Posts: 1,619
Germany
Scorpion Offline OP
Serious User
Scorpion  Offline OP
Serious User

Joined: Jan 2007
Posts: 1,619
Germany
err...i guess i am not sure if that is that where i am looking 4

Re: How does vec_to_angle work? [Re: Scorpion] #125455
04/21/07 17:22
04/21/07 17:22
Joined: Mar 2006
Posts: 2,503
SC, United States
xXxGuitar511 Offline
Expert
xXxGuitar511  Offline
Expert

Joined: Mar 2006
Posts: 2,503
SC, United States
Not 100% sure, but I'm pretty sure this is how it works...

// get the length of the vector
length = vec_length(input);

// get the percentage used of each direction
percent.x = input.x / length;
percent.y = input.y / length;
percent.z = input.z / length;

// use trig to convert to angles (MINE IS PROBABLY WRONG...
// BUT ITS SOMETHING LIKE THIS:)
output.pan = acos(percent.x) * asin(percent.y);
output.tilt = acos(percent.x) * acos(percent.y) * asin(percent.z);
output.roll = 0;


This should be correct (looking at the vec_for_angle() description in the manual). Let me know about your results...


xXxGuitar511
- Programmer
Re: How does vec_to_angle work? [Re: xXxGuitar511] #125456
04/21/07 21:00
04/21/07 21:00
Joined: Jan 2007
Posts: 1,619
Germany
Scorpion Offline OP
Serious User
Scorpion  Offline OP
Serious User

Joined: Jan 2007
Posts: 1,619
Germany
i have to go off...so i just included it in my script, it dont work.
I'll see tomorrow what is wrong with it, thanks to take u time

Re: How does vec_to_angle work? [Re: Scorpion] #125457
04/21/07 21:35
04/21/07 21:35
Joined: Oct 2006
Posts: 1,245
A
AlbertoT Offline
Serious User
AlbertoT  Offline
Serious User
A

Joined: Oct 2006
Posts: 1,245
Quote:


i mean not how to use it... i mean what this function does




This is one of the most popular function in game programming
Given a vector the function returns a direction

for example you know the coordinates of a player and of a target
player.x ... target.x..etc
You might calculates by yourself the angles of the vector having the player and the target as initial and end points
well the function makes the job for you

Re: How does vec_to_angle work? [Re: AlbertoT] #125458
04/23/07 15:01
04/23/07 15:01
Joined: Mar 2006
Posts: 2,503
SC, United States
xXxGuitar511 Offline
Expert
xXxGuitar511  Offline
Expert

Joined: Mar 2006
Posts: 2,503
SC, United States
Mine was just to show the math, not really ready to go into c-script..

this will though
Code:

function angle_for_vector(&output, &input)
{
var length;
percent[3];

// get the length of the vector
length = vec_length(input);

// get the percentage used of each direction
percent.x = input.x / length;
percent.y = input.y / length;
percent.z = input.z / length;

// use trig to convert to angles (MINE IS PROBABLY WRONG...
// BUT ITS SOMETHING LIKE THIS:)
output.pan = acos(percent.x) * asin(percent.y);
output.tilt = acos(percent.x) * acos(percent.y) * asin(percent.z);
output.roll = 0;
}




xXxGuitar511
- Programmer
Re: How does vec_to_angle work? [Re: xXxGuitar511] #125459
04/23/07 15:09
04/23/07 15:09
Joined: Jan 2007
Posts: 1,619
Germany
Scorpion Offline OP
Serious User
Scorpion  Offline OP
Serious User

Joined: Jan 2007
Posts: 1,619
Germany
i know...i did that so, sorry had not thetime to control it

Page 1 of 2 1 2

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1