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 / Trying to find the direction

Author
Message
Section 812
18
Years of Service
User Offline
Joined: 24th Feb 2008
Location:
Posted: 14th Jan 2013 01:24
This is a little tricky, I need to figure the direction angle of object a at its coordinates to object b.

say object a is standing in the kitchen getting a cup of coffee but not facing object b. and object b is in the living room.

how would I get the angle of object a's 360 degrees to object b.

Section 812
18
Years of Service
User Offline
Joined: 24th Feb 2008
Location:
Posted: 14th Jan 2013 02:42
Nevermind. this seems to work for me

d1#=intersect object(obj1#,x1#,y1#,z1#,x2#,y2#,z2#)
direction#=object angle y(obj2#)
if direction#=dl#<>5 then 'blah blah blah'

Section 812
18
Years of Service
User Offline
Joined: 24th Feb 2008
Location:
Posted: 14th Jan 2013 03:16
forget that, didn't work right.

had to make a invisible compass.

rem make invisible compass
make object box 10000,5,5,5
hide object 10000
position object 10000,x1#,y1#,z1#
point object 10000,x2#,y2#,z2#
north#=object angle y(10000)

unless someone has a better solution.

MrValentine
AGK Backer
15
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 14th Jan 2013 03:25 Edited at: 14th Jan 2013 04:30
EZRotate?

There is a free version on the forum, alternatively check Matrix1Utils [I mention that here as there are just soooo many functions in it lol]

Mage
Valued Member
19
Years of Service
User Offline
Joined: 3rd Feb 2007
Location:
Posted: 14th Jan 2013 04:27
The simplest method is to use Point Object.

Your example mentions Object A and Object B.

Copy the Y angle of Object A. Use Point Object on Object A with Object B's co-ordinates. Here's an important part... use Object A's Y coordinate in the Point Object command, not Object B's. Copy the angle of Object A, this is the angle you are looking for. Restore the Y angle of Object A.

Conceptually this is the simplest method for finding the angle. You might be able to find methods that do this in less lines, with plugins or grinding the math.

Section 812
18
Years of Service
User Offline
Joined: 24th Feb 2008
Location:
Posted: 14th Jan 2013 05:34
I have Matrix1Utils but I couldn't find anything that would give me
what I want, an EXCELLENT plugin though.

my invisible compass works though it's an unnecessary extra object.

@Mage - I believe that's what I need to do, it makes sense. I'll give it a shot.

Thanks guys!

MrValentine
AGK Backer
15
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 14th Jan 2013 09:04 Edited at: 14th Jan 2013 10:35
I thi k the free version of EZRotate is called EZRotate Lite... have a look for it on the forums... I have the paid version and it does exactly what you are looking for

MadBit
VIP Member
Gold Codemaster
17
Years of Service
User Offline
Joined: 25th Jun 2009
Location: Germany
Posted: 14th Jan 2013 10:32
Quote: "I thi k the free version of EZRogate is called EZRotate Lite... have a look for it on the forums... I have the paid version and it does exactly what you are looking for "

it's called EZRotate basic . But I fear the function you need is not present in the free version of EZRotate.

If you have/using eXtendet Rotation you can use XROT GET AXIS ANGLE BETWEEN VECTORS(xrotVecResultAxis, xrotVec1, xrotVec2).

Share your knowledge. It's a way to achieve immortality. (Tenzin Gyatso)
Pixie-Particle-Engine
MrValentine
AGK Backer
15
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 14th Jan 2013 10:39 Edited at: 14th Jan 2013 10:42
MadBit - thanks, and as you can see I had typos in that post lol, something that can indicate me being on my phone, Blind as ever >.< I hope WP8 helps me aleviate that issue, and it should be more functional allowing me to link and do more, Android just locks up all the time... [As does the phone itself]

Aaaaah that is embarrasing, Sorry MadBit - That plugin slipped my mind... hopefully I will think of it next time too! added to bookmarks as punishment!

TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 14th Jan 2013 12:55
If you want a clean, mathematical solution, you can achieve it by using some simple trigonometry.



TheComet

http://blankflankstudios.tumblr.com/
Quote: ""
- Randomness 128
pcRaider
19
Years of Service
User Offline
Joined: 30th May 2007
Location:
Posted: 14th Jan 2013 14:09
Section 812
18
Years of Service
User Offline
Joined: 24th Feb 2008
Location:
Posted: 14th Jan 2013 14:38
@ TheComet - That is perfect, so much simpler.

@ pcRaider - I didn't know there was a Dr. DB, I should read those newsletters more.

Thanks a lot!

MrValentine
AGK Backer
15
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 14th Jan 2013 14:47
pcRaider you have good memory... I am now on Issue 19 and forgot about that

Lukas W
22
Years of Service
User Offline
Joined: 5th Sep 2003
Location: Sweden
Posted: 14th Jan 2013 22:37
Is this something you wanted?



The Taffer (+TaffED)
A thief inspired game along with the mission editor (DBPro). [on hiatus]
Section 812
18
Years of Service
User Offline
Joined: 24th Feb 2008
Location:
Posted: 15th Jan 2013 05:56
Yes, Thanks Lukas W, that made things clear.

chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 15th Jan 2013 11:08
Hi there
I use to do the same as Mage noted, pointing and geting new angle.



Cheers.

I'm not a grumpy grandpa
Mage
Valued Member
19
Years of Service
User Offline
Joined: 3rd Feb 2007
Location:
Posted: 16th Jan 2013 02:27
Quote: "Hi there
I use to do the same as Mage noted, pointing and geting new angle."


Thanks Chafari.
If you decide to use my ghetto method, don't point to the target objects Y value. Use the source Y value instead. To is to prevent the object from rotating on the Z axis. So it doesn't cause the source object to tilt up or down. Otherwise YRotate Object won't restore the source objects rotation properly. It will remain oddly tilted.

chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 16th Jan 2013 13:53
Thanks Mage...I know what you mean...I'll remember next time lol

I'm not a grumpy grandpa
Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 17th Jan 2013 01:17
Quote: "I need to figure the direction angle of object a at its coordinates to object b."


angle = atanfull(bx-ax, by-ay)


As a side note, to determine if an object is facing another, you can take the dot product of the two positions. Positive it's facing it, negative value it's behind it. (or is it the other way around?)

"You're not going crazy. You're going sane in a crazy world!" ~Tick
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 17th Jan 2013 10:32
Quote: "or is it the other way around?"


Nope, what you said is correct.

TheComet

http://blankflankstudios.tumblr.com/
Quote: ""
- Randomness 128
The Zombie Killer
15
Years of Service
User Offline
Joined: 27th Mar 2011
Location: Gold Coast, Australia
Posted: 17th Jan 2013 14:10
@Section 812
You can achieve this by using the sin and cos commands. Take a look at the third person code in the FPSC community mod to help you out.

-TZK

Section 812
18
Years of Service
User Offline
Joined: 24th Feb 2008
Location:
Posted: 18th Jan 2013 01:58
Thanks TZK, I'll check it out.

Login to post a reply

Server time is: 2026-07-07 12:28:18
Your offset time is: 2026-07-07 12:28:18