3D Vector

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

Functions

Types and Values

struct MiaVector3d

Object Hierarchy


Description

A MiaVector3d represents a 3D vector in Euclidian space.

Functions

mia_vector3d_new ()

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

Created a new MiaVector3d initialized with the given components

Parameters

x

component of new vector

 

y

component of new vector

 

z

component of new vector

 

Returns

the new MiaVector3d instance


mia_vector3d_set ()

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

Sets the components of self to the given values

Parameters

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_dup ()

MiaVector3d *
mia_vector3d_dup (const MiaVector3d *orig);

Creating a new instance of orig by duplicating it.

Parameters

orig

a Mia3DVector

 

Returns

a new MiaVector3d


mia_vector3d_normalize ()

MiaVector3d *
mia_vector3d_normalize (MiaVector3d *self);

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

Parameters

self

a MiaVector3d

 

Returns

self (for convinience)


mia_vector3d_dot ()

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

Evaluate the dot product of a and b

Parameters

a

a MiaVector3d

 

b

a MiaVector3d

 

Returns

the dot product


mia_vector3d_get_norm ()

gfloat
mia_vector3d_get_norm (MiaVector3d *self);

Evaluate the Euclidian norm of self .

Parameters

self

a 3D vector

 

Returns

the norm


mia_vector3d_copy ()

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

Copies the contens of src to dest

Parameters

dest

Existing MiaVector3d instance

 

src

Existing MiaVector3d instance

 

Returns

dest (for convinience)


mia_vector3d_scale ()

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

Scales self by factor f .

Parameters

self

3D vector to be scaled

 

f

scaling factor

 

Returns

(scaled) self for convinience


mia_vector3d_addup ()

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

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

Parameters

self

This Mia3DVector will be changed

 

other

second 3D vector

 

Returns

self (for convinience)


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.

Parameters

self

input Mia3DVector

 

other

input Mia3DVector

 

result

output Mia3DVector

 

Returns

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


mia_vector3d_equal ()

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

Componentwise comparison of a and b .

Parameters

a

input Mia3DVector

 

b

input Mia3DVector

 

Returns

TRUE if a and b are equal, FALSE otherwise


mia_vector3d_xmlio_read ()

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

Callback to read the vector from a XML file

Parameters

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

Parameters

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

Types and Values

struct MiaVector3d

struct MiaVector3d {
	gfloat x, y, z;
};

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