Inviwo  0.9.10.1
Inviwo documentation
inviwo::SpatialEntity< N > Class Template Referenceabstract

A convenience class to generate transformation matrices between the different coordinate systems in use. More...

#include <spatialdata.h>

+ Inheritance diagram for inviwo::SpatialEntity< N >:

Public Member Functions

 SpatialEntity (const SpatialEntity< N > &rhs)
 
 SpatialEntity (const Matrix< N+1, float > &modelMatrix)
 
 SpatialEntity (const Matrix< N+1, float > &modelMatrix, const Matrix< N+1, float > &worldMatrix)
 
SpatialEntity< N > & operator= (const SpatialEntity< N > &that)
 
virtual SpatialEntity< N > * clone () const =0
 
Vector< N, float > getOffset () const
 
void setOffset (const Vector< N, float > &offset)
 
Matrix< N, float > getBasis () const
 
void setBasis (const Matrix< N, float > &basis)
 
Matrix< N+1, float > getModelMatrix () const
 
void setModelMatrix (const Matrix< N+1, float > &modelMatrix)
 
Matrix< N+1, float > getWorldMatrix () const
 
void setWorldMatrix (const Matrix< N+1, float > &worldMatrix)
 
virtual const SpatialCoordinateTransformer< N > & getCoordinateTransformer () const
 
virtual const SpatialCameraCoordinateTransformer< N > & getCoordinateTransformer (const CameraND< N > &camera) const
 

Protected Attributes

SpatialCoordinateTransformer< N > * transformer_
 
SpatialCameraCoordinateTransformer< N > * cameraTransformer_
 
Matrix< N+1, float > modelMatrix_
 
Matrix< N+1, float > worldMatrix_
 

Detailed Description

template<unsigned int N>
class inviwo::SpatialEntity< N >

A convenience class to generate transformation matrices between the different coordinate systems in use.

This file is auto generated using tools/codegen/coordinatetransforms.nb

Space Description Range

Data raw data numbers generally (-inf, inf), ([0,1] for textures) Model model space coordinates (data min, data max) World world space coordinates (-inf, inf) View view space coordinates (-inf, inf) Clip clip space coordinates [-1,1] Index voxel index coordinates [0, number of voxels)

From Space To Space Transform Entity Member

Data Model ModelMatrix const SpatialEntity<N>* entity_ Model World WorldMatrix const SpatialEntity<N>* entity_ World View ViewMatrix const CameraND<N>* camera_ View Clip ProjectionMatrix const CameraND<N>* camera_ Data Index IndexMatrix const StructuredGridEntity<N>* entity_

┌───────────────────────────────────────────────────────────┐

│ Spatial │

│ ModelM. WorldM. │

│ ┌────────┐──────────▶┌────────┐───────────▶┌────────┐ │

│ │ │ │ │ │ │ │

│ │ Data │ │ Model │ │ World │ │

│ │ │ ModelM.-1 │ │ WorldM.-1 │ │ │

│ └────────┘◀──────────└────────┘◀───────────└────────┘ │

│ │ ▲ │ ▲ │

└───┼────────┼─────────────────────────────────┼───── ┼───┘

│ I │ │ V │

I │ n │ V │ i │

n │ d │ i │ e │

d │ e │ e │ w │

e │ x │ w │ M │

x │ M │ M │ - │

M │ - │ │ 1 │

│ 1 │ │ │

┌───┼────────┼────┐ ┌───┼────────┼────────────────────────────┐ │ │ │ │ │ │ │ │ │ ▼ │ │ │ ▼ │ ProjectionM │ │ ┌────────┐ │ │ ┌────────┐──────────────▶┌────────┐ │ │ │ │ │ │ │ │ │ │ │ │ │ Index │ │ │ │ View │ │ Clip │ │ │ │ │ │ │ │ │ ProjectionM-1 │ │ │ │ └────────┘ │ │ └────────┘◀──────────────└────────┘ │ │ │ │ │ │ Structured │ │ Camera │ └─────────────────┘ └─────────────────────────────────────────┘

Spatial meta data in Inviwo uses 4 different coordinate systems, they are defined as

  • Index - The voxel indices in the data
  • Data - The corresponding texture coordinates of the data.
  • Model - Defines a local basis and offset for the data.
  • World - Puts the data at a position and angle in the scene.

A matrix is always stored in a 1 dim array, for example a 4x4 matrix would be: m = (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16) in c/c++, that uses row major, that translates to a matrix like

m[0][0]=1  m[0][1]=2  m[0][2]=3  m[0][3]=4
m[1][0]=5  m[1][1]=6  m[1][2]=7  m[1][3]=8
m[2][0]=9  m[2][1]=10 m[2][2]=11 m[2][3]=12
m[3][0]=13 m[3][1]=14 m[3][2]=15 m[3][3]=16

here the first index represent the row and the second the column: m[row][column]. On the gpu, that uses column major, the same array would look like:

m[0][0]=1  m[1][0]=5  m[2][0]=9  m[3][0]=13
m[0][1]=2  m[1][1]=6  m[2][1]=10 m[3][1]=14
m[0][2]=3  m[1][2]=7  m[2][2]=11 m[3][2]=15
m[0][3]=4  m[1][3]=8  m[2][3]=12 m[3][3]=16

here the first index is the column and the second the row: m[column][row]

For example to create a translation matrix for on the gpu you want:

1  0  0 dx
0  1  0 dy
0  0  1 dz
0  0  0  1

That means that in c/c++ you would create a transposed matrix like:

1  0  0  0
0  1  0  0
0  0  1  0
dx dy dz 1

GLM also uses column major hence in glm you write m[column][row] hence you would enter the a translation like:

m[0][0]=1  m[1][0]=0  m[2][0]=0  m[3][0]=dx
m[0][1]=0  m[1][1]=1  m[2][1]=0  m[3][1]=dy
m[0][2]=0  m[1][2]=0  m[2][2]=1  m[3][2]=dz
m[0][3]=0  m[1][3]=0  m[2][3]=0  m[3][3]=1

This means that they have the same representation as on the gpu.

coordinate-spaces.png

The documentation for this class was generated from the following files: