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.

Newcomers DBPro Corner / find a point between two objects

Author
Message
Kezzla
16
Years of Service
User Offline
Joined: 21st Aug 2008
Location: Where beer does flow and men chunder
Posted: 15th Jun 2012 06:11 Edited at: 15th Jun 2012 06:20
hi, I've been trying to work out a way to find a point between two objects.

I have a way worked out but it requires a lot of messing around.

At the moment i'm using an object placing it at object one co-ordinates. pointing at object2, finding the distance between the objects with the sqrt function and moving forward half of that.

I figure there has to be a simple mathematical way to do this.

Maths isn't my strong subject so I'm struggling a bit. Ive been looking into trigonometry but its making my eyes role a little.

I know i can get side a and side b from subtracting the objects x and y co-ordinates.

i know that i can square side A and side B add them together and get the square root which will give me the hypotenuse.

I then half the hypotenuse giving me the distance along the hyp that the point should be... and somehow turn the formulas around to find the new side a and b so i can find my halfway point on the corner of the triangle....

not sure how to find two sides with only the hypotenuse.

if there is a simpler way please suggest it.
thankyou.
kezzla

edit:

LOL - I was trying so hard to use trigonometry that I completely overlooked the simple solution of just halving side A and side B!

silly silly silly. Oh well, the topics here if anyone else is confused by it.

still post any idea on easy point finding maths if you want.
thanks
/edit


Sometimes I like to use words out of contents
Hodgey
15
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 15th Jun 2012 13:41
And here's a simple solution in code.



Basically, say we have point O(x1, y1, z1) and point P(x2, y2, z2).

The midpoint M is ( (x1 + x2)/2 , (y1 + y2)/2, (z1 + z2)/2 ).

Login to post a reply

Server time is: 2024-11-21 23:33:31
Your offset time is: 2024-11-21 23:33:31