www.jpct.net

jPCT-AE - a 3d engine for Android => Support => Topic started by: sushobhit on February 14, 2014, 07:53:30 am

Title: Calculate distance between two Objects (get Simple Vector x,y,z)
Post by: sushobhit on February 14, 2014, 07:53:30 am
Hi friends ,
I was working on a project in jpct regarding spaceship sim. And some point in the program I needed to calculate distance beetween two objects. I want a SimpleVector that contains the info of the distance in terms of all the three axis. To be more specific :

SimpleVector distance = Object1.getDistance(Object2); //This should return the simplevector form

is there some function to get this form of distance ?????? Maybe I am overlooking something cause I checked all the parameters of Object3d & SimpleVector Classes but could'nt find any such function ?????
Title: Re: Calculate distance between two Objects (get Simple Vector x,y,z)
Post by: EgonOlsen on February 14, 2014, 08:08:05 am
Something like this should work:
Code: [Select]
SimpleVector distVect=obj2.getTransformedCenter().calcSub(obj1.getTransformedCenter());
Title: Re: Calculate distance between two Objects (get Simple Vector x,y,z)
Post by: sushobhit on February 14, 2014, 02:08:03 pm
Thanks ,
I got it !!!!!