calculating distance between 3dobjects

Software: Away3D 4.x

Avatar
maddog, Sr. Member
Posted: 23 November 2011 01:21 AM   Total Posts: 118

Is there a method to calculate distances between two 3d objects?
Did a search, ,but couldn’t find it.

Thanks for any help!

   

Alex Bogartz, Sr. Member
Posted: 23 November 2011 01:39 AM   Total Posts: 216   [ # 1 ]

Just take their position object and grab the x, y, and z of both objects.

Then:

distance=sqrt(((x1-x2)*(x1-x2))+((y1-y2)*(y1-y2))+((z1-z2)*(z1-z2)))

Make sure each model is centered when you export.

   

Avatar
maddog, Sr. Member
Posted: 23 November 2011 02:10 AM   Total Posts: 118   [ # 2 ]

thanks.

   

Avatar
maddog, Sr. Member
Posted: 23 November 2011 05:56 AM   Total Posts: 118   [ # 3 ]

It seems I have a problem getting distances. The model is a Rubik cube and I have aligned all the cubes origin to the center of the stage in blender. This makes it so when I go to rotate a side it will rotate like a actual Rubik cube rotates. The problem is, I need to get the distance of each cube to each of the sides centers cube. So when i goes to rotate a side i rotate the right cubes according to how close they are to the center cubes.

I have made up version where the origins are set to each cube of the Rubik cube, but I think it would be impossible to solve once you mess it up enough.

here is with origins set to center of each cube
http://www.lukascanoe.com/away3d/Cube.html

here is with origins set to center of stage
http://www.lukascanoe.com/away3d/cube/Cube.html

just click on center cube for each side.

Any Ideas how I could still calculate distances would be great.
Thanks in advance

   

Avatar
maddog, Sr. Member
Posted: 24 November 2011 01:24 AM   Total Posts: 118   [ # 4 ]

Guess no one has any ideas on my problem. : (

   

Avatar
maddog, Sr. Member
Posted: 26 November 2011 08:00 AM   Total Posts: 118   [ # 5 ]

RESOLVED: Figured out a different way to do it.

   

Jack Dracon, Newbie
Posted: 28 November 2011 12:17 PM   Total Posts: 27   [ # 6 ]

Hey,
To calculate the distance between objects, I suggest to you a static function from Vec3 class. That returns a number(how much minor is this value more closer they are).
Goooood Lucky!?

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X