How to Retrieve an vgObject's WCS Position

 

Vega Code Example

 

 

 

 

 

 
 

This example function illustrates :

  • How to get the position of a vgObject in Wold coordinates
  • How to get the just the X, Y,  Z coordinates of a vgObject
  • How to get the just  H, P, R coordinates of a vgObject
  • How to get the X,Y, Z,H,P,R coordinates of a vgObject
  • How to use vgDelete
  • How create a vgPos instance
  • How to delete a vgPos instance
  • How to get the vgObject position with vpGetPos

 

 
   
 

 

 
 
 
    
 

 

#include "vg.h"          // Required for the standard Vega classes
#include "vgperf.h"      // Required for the vgGetXXXPfNode functions

 

void

getVegaObjectsWorldXYZ( vgObject *obj, float *x, float *y, float *z ){

// ##################################################################

// # Public  function  

// #

// #   Function shows to retrieve the current World(WCS) X,Y,Z

// #   coordinates of the give Vega Object

// #

// ##################################################################

float       d   = 0.0f;

vgPosition *pos = NULL;

 

    

    //

    //  Sanity check we need a vgObject

    //     

    if( obj == NULL )

        return;

 

 

    //

    //  Create a vgPos

    //     

    pos = vgNewPos();

    if( pos == NULL )

        return;

 

    

    //

    //  Retrieve the current World(WCS) position from the object

    //     

    vgGetWCSPos( obj, pos );

 

 

    //

    //  Now retrieve the position translation vector

    //     

    vgGetPos( pos, x, y, z, d, d, d );

 

 

 

    //

    //  Release the vgPos as where done

    //     

    vgDelPos( pos);

 

} // getVegaObjectsWorldXYZ

 

 

void

getVegaObjectsWorldHPR( vgObject *obj, float *h, float *p, float *r ){

// ##################################################################

// # Public  function  

// #

// #   Function shows to retrieve the current World(WCS) H,P,R

// #   coordinates of the give Vega Object

// #

// ##################################################################

float       d   = 0.0f;

vgPosition *pos = NULL;

 

    

    //

    //  Sanity check we need a vgObject

    //     

    if( obj == NULL )

        return;

 

 

    //

    //  Create a vgPos

    //     

    pos = vgNewPos();

    if( pos == NULL )

        return;

 

    

    //

    //  Retrieve the current World(WCS) position from the object

    //     

    vgGetWCSPos( obj, pos );

 

 

   //

    //  Now retrieve the positions orientation vector

    //     

    vgGetPos( pos, d, d, d, h, p, r );

 

 

 

    //

    //  Release the vgPos as where done

    //     

    vgDelPos( pos);

 

} // getVegaObjectsWorldHPR

 

 

 

void

getVegaObjectsWorldPos( vgObject *obj

                      , float *x, float *y, float *z

                      , float *h, float *p, float *r ){

 

// ##################################################################

// # Public  function  

// #

// #   Function shows to retrieve the current World(WCS) X,Y,Z H,P,R

// #   coordinates of the give Vega Object

// #

// ##################################################################

vgPosition *pos = NULL;

 

    

    //

    //  Sanity check we need a vgObject

    //     

    if( obj == NULL )

        return;

 

 

    //

    //  Create a vgPos

    //     

    pos = vgNewPos();

    if( pos == NULL )

        return;

 

    

    //

    //  Retrieve the current World(WCS) position from the object

    //     

    vgGetWCSPos( obj, pos );

 

 

    //

    //  Now retrieve the position translation vector

    //     

    vgGetPos( pos, x, y, z, h, p, r );

 

 

 

    //

    //  Release the vgPos as where done

    //     

    vgDelPos( pos);

 

} // getVegaObjectsWorldPos

 

 

  

   

 
    
 

 

 

Copyright 2004 Gordon Tomlinson  All Rights Reserved.

All logos, trademarks and copyrights in this site are property of their respective owner.