3D Vector

3D Vector — A 3D vector in Euclidian space.

Synopsis

                    MiaVector3d;
MiaVector3d *       mia_vector3d_add                    (const MiaVector3d *self,
                                                         const MiaVector3d *other,
                                                         MiaVector3d *result);
MiaVector3d *       mia_vector3d_addup                  (MiaVector3d *self,
                                                         const MiaVector3d *other);
MiaVector3d *       mia_vector3d_copy                   (MiaVector3d *dest,
                                                         const MiaVector3d *src);
gfloat              mia_vector3d_dot                    (const MiaVector3d *a,
                                                         const MiaVector3d *b);
MiaVector3d *       mia_vector3d_dup                    (const MiaVector3d *orig);
gboolean            mia_vector3d_equal                  (const MiaVector3d *a,
                                                         const MiaVector3d *b);
gfloat              mia_vector3d_get_norm               (MiaVector3d *self);
MiaVector3d *       mia_vector3d_new                    (gfloat x,
                                                         gfloat y,
                                                         gfloat z);
MiaVector3d *       mia_vector3d_normalize              (MiaVector3d *self);
MiaVector3d *       mia_vector3d_scale                  (MiaVector3d *self,
                                                         gfloat f);
MiaVector3d *       mia_vector3d_set                    (MiaVector3d *self,
                                                         gfloat x,
                                                         gfloat y,
                                                         gfloat z);
void                mia_vector3d_xmlio_read             (ParserState *state,
                                                         const gchar *property);
gboolean            mia_vector3d_xmlio_write            (xmlNodePtr parent,
                                                         xmlNsPtr ns,
                                                         const gchar *tag,
                                                         const MiaVector3d *v);

Description

A MiaVector3d represents a 3D vector in Euclidian space.

Details

MiaVector3d

typedef struct _MiaVector3d MiaVector3d;

This defines a 3D vector with elements x,y,z.


mia_vector3d_add ()

MiaVector3d *       mia_vector3d_add                    (const MiaVector3d *self,
                                                         const MiaVector3d *other,
                                                         MiaVector3d *result);

Adds self and other component wise and stores the result in result. if result = NULL, then a new Mia3DVector instance is created and returned.

self :

input Mia3DVector

other :

input Mia3DVector

result :

output Mia3DVector

Returns :

if result != NULL then result, else a newly created Mia3DVector

mia_vector3d_addup ()

MiaVector3d *       mia_vector3d_addup                  (MiaVector3d *self,
                                                         const MiaVector3d *other);

Adds other to self componentwise (equivalent to self += other

self :

This Mia3DVector will be changed

other :

second 3D vector

Returns :

self (for convinience)

mia_vector3d_copy ()

MiaVector3d *       mia_vector3d_copy                   (MiaVector3d *dest,
                                                         const MiaVector3d *src);

Copies the contens of src to dest

dest :

Existing MiaVector3d instance

src :

Existing MiaVector3d instance

Returns :

dest (for convinience)

mia_vector3d_dot ()

gfloat              mia_vector3d_dot                    (const MiaVector3d *a,
                                                         const MiaVector3d *b);

Evaluate the dot product of a and b

a :

a MiaVector3d

b :

a MiaVector3d

Returns :

the dot product

mia_vector3d_dup ()

MiaVector3d *       mia_vector3d_dup                    (const MiaVector3d *orig);

Creating a new instance of orig by duplicating it.

orig :

a Mia3DVector

Returns :

a new MiaVector3d

mia_vector3d_equal ()

gboolean            mia_vector3d_equal                  (const MiaVector3d *a,
                                                         const MiaVector3d *b);

Componentwise comparison of a and b.

a :

input Mia3DVector

b :

input Mia3DVector

Returns :

TRUE if a and b are equal, FALSE otherwise

mia_vector3d_get_norm ()

gfloat              mia_vector3d_get_norm               (MiaVector3d *self);

Evaluate the Euclidian norm of self.

self :

a 3D vector

Returns :

the norm

mia_vector3d_new ()

MiaVector3d *       mia_vector3d_new                    (gfloat x,
                                                         gfloat y,
                                                         gfloat z);

Created a new MiaVector3d initialized with the given components

x :

component of new vector

y :

component of new vector

z :

component of new vector

Returns :

the new MiaVector3d instance

mia_vector3d_normalize ()

MiaVector3d *       mia_vector3d_normalize              (MiaVector3d *self);

Normalize self to have a norm of 1 (if the vector is not zero)

self :

a MiaVector3d

Returns :

self (for convinience)

mia_vector3d_scale ()

MiaVector3d *       mia_vector3d_scale                  (MiaVector3d *self,
                                                         gfloat f);

Scales self by factor f.

self :

3D vector to be scaled

f :

scaling factor

Returns :

(scaled) self for convinience

mia_vector3d_set ()

MiaVector3d *       mia_vector3d_set                    (MiaVector3d *self,
                                                         gfloat x,
                                                         gfloat y,
                                                         gfloat z);

Sets the components of self to the given values

self :

This Mia3DVector will be changed

x :

new x component

y :

new y component

z :

new z component

Returns :

self (with the new values set)

mia_vector3d_xmlio_read ()

void                mia_vector3d_xmlio_read             (ParserState *state,
                                                         const gchar *property);

Callback to read the vector from a XML file

state :

holst the current state of the XML SAX parser

property :

the name of the property, where the MiaVector3d should be stored

mia_vector3d_xmlio_write ()

gboolean            mia_vector3d_xmlio_write            (xmlNodePtr parent,
                                                         xmlNsPtr ns,
                                                         const gchar *tag,
                                                         const MiaVector3d *v);

Add vector v as XML node with tag tag to the parent node

parent :

node to attach the vector to

ns :

xml name space

tag :

XML tag of the node

v :

a MiaVector3d to be stored

Returns :

TRUE if vector was NULL or sucessfully added to the xml node FALSE otherwise