Author Topic: Calculate distance between two Objects (get Simple Vector x,y,z)  (Read 2572 times)

Offline sushobhit

  • long
  • ***
  • Posts: 109
  • future is now
    • View Profile
    • ANDROID APPS
Calculate distance between two Objects (get Simple Vector x,y,z)
« 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 ?????

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Calculate distance between two Objects (get Simple Vector x,y,z)
« Reply #1 on: February 14, 2014, 08:08:05 am »
Something like this should work:
Code: [Select]
SimpleVector distVect=obj2.getTransformedCenter().calcSub(obj1.getTransformedCenter());

Offline sushobhit

  • long
  • ***
  • Posts: 109
  • future is now
    • View Profile
    • ANDROID APPS
Re: Calculate distance between two Objects (get Simple Vector x,y,z)
« Reply #2 on: February 14, 2014, 02:08:03 pm »
Thanks ,
I got it !!!!!