Python_2  1.0
Functions
_12_tet Namespace Reference

Draws a 3D tetrahedron and allows a user to rotate it (mouse left button and wheel). More...

Functions

def createZeroMat (m, n)
 
def matMul (mat1, mat2)
 
def matTrans (mat)
 
def translate (x, y, dx, dy)
 
def drawTet (tet, col)
 
def init ()
 
def cbClicked (event)
 
def cbMottion (event)
 
def wheelUp (event)
 
def wheelDown (event)
 
def wheel (event)
 
def resize (event)
 
def main ()
 

Detailed Description

Draws a 3D tetrahedron and allows a user to rotate it (mouse left button and wheel).

The Tetrahedron is represented by a 3 x 4 matrix. Each column represents a 3D vertex.

note: a m x n matrix is represented by a list of lines: [[l_1] [l_2] .. [l_m]]. m = len(mat), n = len(mat[0]), mat(i,j) = mat[i][j]

Author
Paulo Roma
Since
01/05/2014
See also
http://www.orimosenzon.com/wiki/index.php/Python_samples
http://mathworld.wolfram.com/RotationMatrix.html
https://code.activestate.com/recipes/578876-rotatable-tetrahedron/

Function Documentation

◆ cbClicked()

def _12_tet.cbClicked (   event)
Save current mouse position.

Referenced by cbMottion().

◆ cbMottion()

def _12_tet.cbMottion (   event)
Map mouse displacements in Y direction to rotations about X axis,
   and mouse displacements in X direction to rotations about Y axis.

References cbClicked(), drawTet(), _12a_poly.EPS(), matMul(), _12a_poly.ROT_X(), and _12a_poly.ROT_Y().

◆ createZeroMat()

def _12_tet.createZeroMat (   m,
  n 
)
Return a matrix (m x n) filled with zeros.

Referenced by matMul(), and matTrans().

◆ drawTet()

def _12_tet.drawTet (   tet,
  col 
)
Draw a tetrahedron.

References translate().

Referenced by cbMottion(), main(), resize(), wheel(), wheelDown(), and wheelUp().

◆ init()

def _12_tet.init ( )
Initialize global variables.

References _12a_poly.EPS(), _12a_poly.eps(), matTrans(), _12a_poly.ROT_X(), _12a_poly.ROT_Y(), and _12a_poly.ROT_Z().

Referenced by main().

◆ main()

def _12_tet.main ( )

References drawTet(), and init().

◆ matMul()

def _12_tet.matMul (   mat1,
  mat2 
)
Return mat1 x mat2 (mat1 multiplied by mat2).

References createZeroMat().

Referenced by cbMottion(), wheel(), wheelDown(), and wheelUp().

◆ matTrans()

def _12_tet.matTrans (   mat)
Return mat (n x m) transposed (m x n).

References createZeroMat().

Referenced by init().

◆ resize()

def _12_tet.resize (   event)
Redraw the tetrahedron, in case of a window change due to user resizing it.

References drawTet().

◆ translate()

def _12_tet.translate (   x,
  y,
  dx,
  dy 
)
Translate vector(x,y) by (dx,dy).

Referenced by drawTet().

◆ wheel()

def _12_tet.wheel (   event)
Map mouse wheel displacements to rotations about Z axis.

References drawTet(), _12a_poly.EPS(), matMul(), and _12a_poly.ROT_Z().

◆ wheelDown()

def _12_tet.wheelDown (   event)
Map mouse wheel down displacements to rotations about Z axis.

References drawTet(), _12a_poly.EPS(), matMul(), and _12a_poly.ROT_Z().

◆ wheelUp()

def _12_tet.wheelUp (   event)
Map mouse wheel up displacements to rotations about Z axis.

References drawTet(), _12a_poly.EPS(), matMul(), and _12a_poly.ROT_Z().