View topic - Angles, Directions, Trig...

 All times are UTC + 1 hour

 Page 1 of 1 [ 10 posts ]
 Print view Previous topic | Next topic
Author Message
 Post subject: Angles, Directions, Trig...Posted: 21 Mar 2012, 15:39
 Map Creator

Joined: 12 Jan 2005, 10:25
Location: Still signing off after all these years
 Hi guys, working on a script for a unit and running into a whole load of mindslopionation re what the games returning angle wise.Code:unitdir1,unitdir2,unitdir3 = Spring.GetUnitDirection(unitID)in this case am I right in thinking that unitdir1 will be which way the unit is facing? In which case where's that measured from (IE is that from "north" "south" "east" or "west"). Also am I right in thinking this is returning (stupidly) values from -pi to pi? (Instead of 0 to 2pi which is what I expected... I take it theres a reason...)ThanksaGorm

 Post subject: Re: Angles, Directions, Trig...Posted: 21 Mar 2012, 19:23
 Kernel Panic Co-Developer

Joined: 16 Nov 2004, 13:08
 I would say unitdir1, unitdir2, unitdir3 are the cartesian coordinates (that, is, the X, the Y, the Z) of a vertex. This vertex direction is the same as the unit direction.So no, they are not angles in the [-pi,pi] range. They are coordinates in the [-1,1] range (assuming the vertex is normalised).Mostly a guess, though.

 Post subject: Re: Angles, Directions, Trig...Posted: 21 Mar 2012, 21:13
 Moderator

Joined: 29 Apr 2005, 00:14
Location: #moddev - join it!
 zwzsg wrote:I would say unitdir1, unitdir2, unitdir3 are the cartesian coordinates (that, is, the X, the Y, the Z) of a vertex. This vertex direction is the same as the unit direction.So no, they are not angles in the [-pi,pi] range. They are coordinates in the [-1,1] range (assuming the vertex is normalised).Mostly a guess, though.Would be my guess / recollection also.

 Post subject: Re: Angles, Directions, Trig...Posted: 22 Mar 2012, 10:49
 Map Creator

Joined: 12 Jan 2005, 10:25
Location: Still signing off after all these years
 Ok, you've both really lost me there? Are you saying that they are the coordinates of a point which a line from the unit center would travel though that is pointing in the direction the unit is facing?IE, if unitdir1=1 and the others are all 0 the unit is facing towards X? And if unitdir1=0.5 then either unitdir2 or 3 would be 0.866...ish?If so thats fine I can work with that, it's just a pain in the arse and I can't imagin why anyone would need those values in that format... (I assume there is some cool math that you can do with it though and someone who's good at math will prob look at my script and go why the hell is he doing everything like this?)aGorm

 Post subject: Re: Angles, Directions, Trig...Posted: 22 Mar 2012, 13:39
 Moderator

Joined: 12 Oct 2007, 08:24
 It's just a vector, they are quite useful.If you want x,z direction use this:Code:dir = Spring.GetUnitHeading(unitID)/32768*math.pi

 Post subject: Re: Angles, Directions, Trig...Posted: 22 Mar 2012, 13:56
 Map Creator

Joined: 12 Jan 2005, 10:25
Location: Still signing off after all these years
 Thanks... out of intrest whats the /32768 for? Just some magic constant?aGorm

 Post subject: Re: Angles, Directions, Trig...Posted: 22 Mar 2012, 14:13
 Moderator

Joined: 12 Oct 2007, 08:24
 32768 = 2^15There are 2^16 heading units in a circle and 2pi radians in a circle.

 Post subject: Re: Angles, Directions, Trig...Posted: 22 Mar 2012, 14:24
 Map Creator

Joined: 12 Jan 2005, 10:25
Location: Still signing off after all these years
 That explains why when I tryed it with heading everything went weird... I assumed it returned in radians.aGorm

 Post subject: Re: Angles, Directions, Trig...Posted: 22 Mar 2012, 14:52

Joined: 17 Mar 2009, 00:20
 aGorm wrote:Thanks... out of intrest whats the /32768 for? Just some magic constant?aGorm32768 binary number

 Post subject: Re: Angles, Directions, Trig...Posted: 22 Mar 2012, 15:22
 Map Creator

Joined: 12 Jan 2005, 10:25
Location: Still signing off after all these years
 Woohahahha it works. After a lot of head banging I have 3 legs positioned with the power of math! It's strange how you forget how trig works when you havn't done it for 10 years...not that this pic explains much but the legs are positioned by the numbers echoing at the top, which are worked out from 3 empty peices in the root of the object and then ofset by the unit rotation. (by default all the legs are just pointing stright back...)Attachment: itworkshahaha.jpg [89.29 KiB] Downloaded 2 times This means I can now feed in cordinates of where the leg was previously and move it to there, and thus create the illusion of the feet sticking to the ground... well after I get the legs to also extend out to the points aswell... more math... aGorm

 Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending
 Page 1 of 1 [ 10 posts ]

 All times are UTC + 1 hour

Who is online

Users browsing this forum: No registered users and 0 guests

 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum

Search for:
 Jump to:  Select a forum ------------------ Spring    Community News       News Submissions    General Discussion    Help & Bugs    Game Lobby       Spring Clans       Lobby Clients    Tournaments    Linux    Mac OS X    Off Topic Discussion Content Creation    Game Development       Game Development Tutorials & Resources    Map Creation       Map Tutorials & Resources    Art & Modelling       Modelling & Texturing Tutorials & Resources    Project Subforums       Kernel Panic       Zero-K       Balanced Annihilation       Spring: 1944       Star Wars: Imperial Winter       XTA       Supreme Annihilation       Caydr's Projects       Evolution RTS       Argh's Projects       The Cursed       NOTA       Damned       Conflict Terra       Engines Of War       Spring Tanks       Journeywar       BattleTech: Legacy       Dune: Evolution       Progressive Annihilation       TA: Factions    Sound Effects & Music Development    News    Development       Dedicated Developer Discussion       New Developer Discussion       Infrastructure Development       Meeting Minutes    AI    Feature Requests    Lua Scripts       The Werewolf Game Site content    Site content       Banners       Welcome images       Videos       Videos - contributions       Screenshots       Screenshots - contributions