Mesh Oriented datABase  (version 5.5.1)
An array-based unstructured mesh library
moab::HomXform Class Reference

Homogeneous coordinate transformation matrix. More...

#include <HomXform.hpp>

+ Collaboration diagram for moab::HomXform:

Public Member Functions

 HomXform (const int matrix[16])
 constructor from matrix More...
 
 HomXform ()
 bare constructor More...
 
 HomXform (const int rotate[9], const int scale[3], const int translate[3])
 constructor from rotation, scaling, translation More...
 
 HomXform (int i1, int i2, int i3, int i4, int i5, int i6, int i7, int i8, int i9, int i10, int i11, int i12, int i13, int i14, int i15, int i16)
 constructor taking 16 ints, useful for efficient operators More...
 
 HomXform (HomXform const &from)
 copy constructor More...
 
HomXform inverse () const
 return this.inverse More...
 
void three_pt_xform (const HomCoord &p1, const HomCoord &q1, const HomCoord &p2, const HomCoord &q2, const HomCoord &p3, const HomCoord &q3)
 compute a transform from three points More...
 
int operator[] (const int &count) const
 operators More...
 
int & operator[] (const int &count)
 
bool operator== (const HomXform &rhs) const
 
bool operator!= (const HomXform &rhs) const
 
HomXformoperator= (const HomXform &rhs)
 
HomXformoperator*= (const HomXform &rhs)
 
HomXform operator* (const HomXform &rhs2) const
 

Static Public Attributes

static MOAB_EXPORT HomXform IDENTITY
 

Private Attributes

int xForm [16]
 the matrix; don't bother storing the last column, since we assume for now it's always unused More...
 

Friends

class HomCoord
 

Detailed Description

Homogeneous coordinate transformation matrix.

Definition at line 147 of file HomXform.hpp.

Constructor & Destructor Documentation

◆ HomXform() [1/5]

moab::HomXform::HomXform ( const int  matrix[16])
inline

constructor from matrix

Definition at line 497 of file HomXform.hpp.

498 {
499  for( int i = 0; i < 16; i++ )
500  xForm[i] = matrix[i];
501 }

References xForm.

◆ HomXform() [2/5]

moab::HomXform::HomXform ( )
inline

bare constructor

Definition at line 503 of file HomXform.hpp.

503 {}

Referenced by inverse(), operator*(), operator*=(), and three_pt_xform().

◆ HomXform() [3/5]

moab::HomXform::HomXform ( const int  rotate[9],
const int  scale[3],
const int  translate[3] 
)
inline

constructor from rotation, scaling, translation

Definition at line 505 of file HomXform.hpp.

506 {
507  int i, j;
508  for( i = 0; i < 3; i++ )
509  {
510  for( j = 0; j < 3; j++ )
511  xForm[i * 4 + j] = rotate[i * 3 + j] * scale[j];
512 
513  xForm[12 + i] = translate[i];
514  }
515  xForm[3] = 0;
516  xForm[7] = 0;
517  xForm[11] = 0;
518  xForm[15] = 1;
519 }

References xForm.

◆ HomXform() [4/5]

moab::HomXform::HomXform ( int  i1,
int  i2,
int  i3,
int  i4,
int  i5,
int  i6,
int  i7,
int  i8,
int  i9,
int  i10,
int  i11,
int  i12,
int  i13,
int  i14,
int  i15,
int  i16 
)
inline

constructor taking 16 ints, useful for efficient operators

Definition at line 521 of file HomXform.hpp.

537 {
538  xForm[0] = i1;
539  xForm[1] = i2;
540  xForm[2] = i3;
541  xForm[3] = i4;
542  xForm[4] = i5;
543  xForm[5] = i6;
544  xForm[6] = i7;
545  xForm[7] = i8;
546  xForm[8] = i9;
547  xForm[9] = i10;
548  xForm[10] = i11;
549  xForm[11] = i12;
550  xForm[12] = i13;
551  xForm[13] = i14;
552  xForm[14] = i15;
553  xForm[15] = i16;
554 }

References xForm.

◆ HomXform() [5/5]

moab::HomXform::HomXform ( HomXform const &  from)
inline

copy constructor

Definition at line 188 of file HomXform.hpp.

189  {
190  std::copy( from.xForm, from.xForm + 16, xForm );
191  }

References xForm.

Member Function Documentation

◆ inverse()

HomXform moab::HomXform::inverse ( ) const
inline

return this.inverse

Definition at line 716 of file HomXform.hpp.

717 {
718 
719  /*
720  // original code:
721 
722  HomXform tmp;
723 
724  // assign the diagonal
725  tmp[0] = xForm[0];
726  tmp[5] = xForm[5];
727  tmp[10] = xForm[10];
728  tmp[15] = xForm[15];
729 
730  // invert the rotation matrix
731  tmp[XFORM_INDEX(0,1)] = XFORM(1,0);
732  tmp[XFORM_INDEX(0,2)] = XFORM(2,0);
733  tmp[XFORM_INDEX(1,0)] = XFORM(0,1);
734  tmp[XFORM_INDEX(1,2)] = XFORM(2,1);
735  tmp[XFORM_INDEX(2,0)] = XFORM(0,2);
736  tmp[XFORM_INDEX(2,1)] = XFORM(1,2);
737 
738  // negative translate * Rinv
739  tmp[XFORM_INDEX(3,0)] = -(XFORM(3,0)*tmp.XFORM(0,0) + XFORM(3,1)*tmp.XFORM(1,0) +
740  XFORM(3,2)*tmp.XFORM(2,0)); tmp[XFORM_INDEX(3,1)] = -(XFORM(3,0)*tmp.XFORM(0,1) +
741  XFORM(3,1)*tmp.XFORM(1,1) + XFORM(3,2)*tmp.XFORM(2,1)); tmp[XFORM_INDEX(3,2)] =
742  -(XFORM(3,0)*tmp.XFORM(0,2) + XFORM(3,1)*tmp.XFORM(1,2) + XFORM(3,2)*tmp.XFORM(2,2));
743 
744  // zero last column
745  tmp[XFORM_INDEX(0,3)] = 0;
746  tmp[XFORM_INDEX(1,3)] = 0;
747  tmp[XFORM_INDEX(2,3)] = 0;
748 
749  // h factor
750  tmp[XFORM_INDEX(3,3)] = 1;
751 
752  return tmp;
753  */
754 
755  // more efficient, but somewhat confusing (remember, column-major):
756 
757  return HomXform(
758  // row 0
759  xForm[0], XFORM( 1, 0 ), XFORM( 2, 0 ), 0,
760  // row 1
761  XFORM( 0, 1 ), xForm[5], XFORM( 2, 1 ), 0,
762  // row 2
763  XFORM( 0, 2 ), XFORM( 1, 2 ), xForm[10], 0,
764  // row 3
765  -( XFORM( 3, 0 ) * xForm[0] + XFORM( 3, 1 ) * XFORM( 0, 1 ) + XFORM( 3, 2 ) * XFORM( 0, 2 ) ),
766  -( XFORM( 3, 0 ) * XFORM( 1, 0 ) + XFORM( 3, 1 ) * xForm[5] + XFORM( 3, 2 ) * XFORM( 1, 2 ) ),
767  -( XFORM( 3, 0 ) * XFORM( 2, 0 ) + XFORM( 3, 1 ) * XFORM( 2, 1 ) + XFORM( 3, 2 ) * xForm[10] ), 1 );
768 }

References HomXform(), XFORM, and xForm.

Referenced by moab::HomCoord::operator/=().

◆ operator!=()

bool moab::HomXform::operator!= ( const HomXform rhs) const
inline

Definition at line 706 of file HomXform.hpp.

707 {
708  return ( xForm[0] != rhs.xForm[0] || xForm[1] != rhs.xForm[1] || xForm[2] != rhs.xForm[2] ||
709  xForm[3] != rhs.xForm[3] || xForm[4] != rhs.xForm[4] || xForm[5] != rhs.xForm[5] ||
710  xForm[6] != rhs.xForm[6] || xForm[7] != rhs.xForm[7] || xForm[8] != rhs.xForm[8] ||
711  xForm[9] != rhs.xForm[9] || xForm[10] != rhs.xForm[10] || xForm[11] != rhs.xForm[11] ||
712  xForm[12] != rhs.xForm[12] || xForm[13] != rhs.xForm[13] || xForm[14] != rhs.xForm[14] ||
713  xForm[15] != rhs.xForm[15] );
714 }

References xForm.

◆ operator*()

HomXform moab::HomXform::operator* ( const HomXform rhs2) const
inline

Definition at line 564 of file HomXform.hpp.

565 {
566  return HomXform(
567  // temp.XFORM(0,0)
568  XFORM( 0, 0 ) * rhs2.XFORM( 0, 0 ) + XFORM( 0, 1 ) * rhs2.XFORM( 1, 0 ) + XFORM( 0, 2 ) * rhs2.XFORM( 2, 0 ) +
569  XFORM( 0, 3 ) * rhs2.XFORM( 3, 0 ),
570  // temp.XFORM(0,1)
571  XFORM( 0, 0 ) * rhs2.XFORM( 0, 1 ) + XFORM( 0, 1 ) * rhs2.XFORM( 1, 1 ) + XFORM( 0, 2 ) * rhs2.XFORM( 2, 1 ) +
572  XFORM( 0, 3 ) * rhs2.XFORM( 3, 1 ),
573  // temp.XFORM(0,2)
574  XFORM( 0, 0 ) * rhs2.XFORM( 0, 2 ) + XFORM( 0, 1 ) * rhs2.XFORM( 1, 2 ) + XFORM( 0, 2 ) * rhs2.XFORM( 2, 2 ) +
575  XFORM( 0, 3 ) * rhs2.XFORM( 3, 2 ),
576  // temp.XFORM(0,3)
577  XFORM( 0, 0 ) * rhs2.XFORM( 0, 3 ) + XFORM( 0, 1 ) * rhs2.XFORM( 1, 3 ) + XFORM( 0, 2 ) * rhs2.XFORM( 2, 3 ) +
578  XFORM( 0, 3 ) * rhs2.XFORM( 3, 3 ),
579 
580  // temp.XFORM(1,0)
581  XFORM( 1, 0 ) * rhs2.XFORM( 0, 0 ) + XFORM( 1, 1 ) * rhs2.XFORM( 1, 0 ) + XFORM( 1, 2 ) * rhs2.XFORM( 2, 0 ) +
582  XFORM( 1, 3 ) * rhs2.XFORM( 3, 0 ),
583  // temp.XFORM(1,1)
584  XFORM( 1, 0 ) * rhs2.XFORM( 0, 1 ) + XFORM( 1, 1 ) * rhs2.XFORM( 1, 1 ) + XFORM( 1, 2 ) * rhs2.XFORM( 2, 1 ) +
585  XFORM( 1, 3 ) * rhs2.XFORM( 3, 1 ),
586  // temp.XFORM(1,2)
587  XFORM( 1, 0 ) * rhs2.XFORM( 0, 2 ) + XFORM( 1, 1 ) * rhs2.XFORM( 1, 2 ) + XFORM( 1, 2 ) * rhs2.XFORM( 2, 2 ) +
588  XFORM( 1, 3 ) * rhs2.XFORM( 3, 2 ),
589  // temp.XFORM(1,3)
590  XFORM( 1, 0 ) * rhs2.XFORM( 0, 3 ) + XFORM( 1, 1 ) * rhs2.XFORM( 1, 3 ) + XFORM( 1, 2 ) * rhs2.XFORM( 2, 3 ) +
591  XFORM( 1, 3 ) * rhs2.XFORM( 3, 3 ),
592 
593  // temp.XFORM(2,0)
594  XFORM( 2, 0 ) * rhs2.XFORM( 0, 0 ) + XFORM( 2, 1 ) * rhs2.XFORM( 1, 0 ) + XFORM( 2, 2 ) * rhs2.XFORM( 2, 0 ) +
595  XFORM( 2, 3 ) * rhs2.XFORM( 3, 0 ),
596  // temp.XFORM(2,1)
597  XFORM( 2, 0 ) * rhs2.XFORM( 0, 1 ) + XFORM( 2, 1 ) * rhs2.XFORM( 1, 1 ) + XFORM( 2, 2 ) * rhs2.XFORM( 2, 1 ) +
598  XFORM( 2, 3 ) * rhs2.XFORM( 3, 1 ),
599  // temp.XFORM(2,2)
600  XFORM( 2, 0 ) * rhs2.XFORM( 0, 2 ) + XFORM( 2, 1 ) * rhs2.XFORM( 1, 2 ) + XFORM( 2, 2 ) * rhs2.XFORM( 2, 2 ) +
601  XFORM( 2, 3 ) * rhs2.XFORM( 3, 2 ),
602  // temp.XFORM(2,3)
603  XFORM( 2, 0 ) * rhs2.XFORM( 0, 3 ) + XFORM( 2, 1 ) * rhs2.XFORM( 1, 3 ) + XFORM( 2, 2 ) * rhs2.XFORM( 2, 3 ) +
604  XFORM( 2, 3 ) * rhs2.XFORM( 3, 3 ),
605 
606  // temp.XFORM(3,0)
607  // xForm[12]*rhs2.xForm[0] + xForm[13]*rhs2.xForm[4] + xForm[14]*rhs2.xForm[8] +
608  // xForm[15]*rhs2.xForm[12]
609  XFORM( 3, 0 ) * rhs2.XFORM( 0, 0 ) + XFORM( 3, 1 ) * rhs2.XFORM( 1, 0 ) + XFORM( 3, 2 ) * rhs2.XFORM( 2, 0 ) +
610  XFORM( 3, 3 ) * rhs2.XFORM( 3, 0 ),
611  // temp.XFORM(3,1)
612  // xForm[12]*rhs2.xForm[1] + xForm[13]*rhs2.xForm[5] + xForm[14]*rhs2.xForm[9] +
613  // xForm[15]*rhs2.xForm[13]
614  XFORM( 3, 0 ) * rhs2.XFORM( 0, 1 ) + XFORM( 3, 1 ) * rhs2.XFORM( 1, 1 ) + XFORM( 3, 2 ) * rhs2.XFORM( 2, 1 ) +
615  XFORM( 3, 3 ) * rhs2.XFORM( 3, 1 ),
616  // temp.XFORM(3,2)
617  // xForm[12]*rhs2.xForm[2] + xForm[13]*rhs2.xForm[6] + xForm[14]*rhs2.xForm[10] +
618  // xForm[15]*rhs2.xForm[14]
619  XFORM( 3, 0 ) * rhs2.XFORM( 0, 2 ) + XFORM( 3, 1 ) * rhs2.XFORM( 1, 2 ) + XFORM( 3, 2 ) * rhs2.XFORM( 2, 2 ) +
620  XFORM( 3, 3 ) * rhs2.XFORM( 3, 2 ),
621  // temp.XFORM(3,3)
622  // xForm[12]*rhs2.xForm[3] + xForm[13]*rhs2.xForm[7] + xForm[14]*rhs2.xForm[11] +
623  // xForm[15]*rhs2.xForm[15]
624  XFORM( 3, 0 ) * rhs2.XFORM( 0, 3 ) + XFORM( 3, 1 ) * rhs2.XFORM( 1, 3 ) + XFORM( 3, 2 ) * rhs2.XFORM( 2, 3 ) +
625  XFORM( 3, 3 ) * rhs2.XFORM( 3, 3 ) );
626 }

References HomXform(), and XFORM.

◆ operator*=()

HomXform & moab::HomXform::operator*= ( const HomXform rhs)
inline

Definition at line 628 of file HomXform.hpp.

629 {
630  *this = HomXform(
631  // temp.XFORM(0,0)
632  XFORM( 0, 0 ) * rhs2.XFORM( 0, 0 ) + XFORM( 0, 1 ) * rhs2.XFORM( 1, 0 ) + XFORM( 0, 2 ) * rhs2.XFORM( 2, 0 ) +
633  XFORM( 0, 3 ) * rhs2.XFORM( 3, 0 ),
634  // temp.XFORM(0,1)
635  XFORM( 0, 0 ) * rhs2.XFORM( 0, 1 ) + XFORM( 0, 1 ) * rhs2.XFORM( 1, 1 ) + XFORM( 0, 2 ) * rhs2.XFORM( 2, 1 ) +
636  XFORM( 0, 3 ) * rhs2.XFORM( 3, 1 ),
637  // temp.XFORM(0,2)
638  XFORM( 0, 0 ) * rhs2.XFORM( 0, 2 ) + XFORM( 0, 1 ) * rhs2.XFORM( 1, 2 ) + XFORM( 0, 2 ) * rhs2.XFORM( 2, 2 ) +
639  XFORM( 0, 3 ) * rhs2.XFORM( 3, 2 ),
640  // temp.XFORM(0,3)
641  XFORM( 0, 0 ) * rhs2.XFORM( 0, 3 ) + XFORM( 0, 1 ) * rhs2.XFORM( 1, 3 ) + XFORM( 0, 2 ) * rhs2.XFORM( 2, 3 ) +
642  XFORM( 0, 3 ) * rhs2.XFORM( 3, 3 ),
643 
644  // temp.XFORM(1,0)
645  XFORM( 1, 0 ) * rhs2.XFORM( 0, 0 ) + XFORM( 1, 1 ) * rhs2.XFORM( 1, 0 ) + XFORM( 1, 2 ) * rhs2.XFORM( 2, 0 ) +
646  XFORM( 1, 3 ) * rhs2.XFORM( 3, 0 ),
647  // temp.XFORM(1,1)
648  XFORM( 1, 0 ) * rhs2.XFORM( 0, 1 ) + XFORM( 1, 1 ) * rhs2.XFORM( 1, 1 ) + XFORM( 1, 2 ) * rhs2.XFORM( 2, 1 ) +
649  XFORM( 1, 3 ) * rhs2.XFORM( 3, 1 ),
650  // temp.XFORM(1,2)
651  XFORM( 1, 0 ) * rhs2.XFORM( 0, 2 ) + XFORM( 1, 1 ) * rhs2.XFORM( 1, 2 ) + XFORM( 1, 2 ) * rhs2.XFORM( 2, 2 ) +
652  XFORM( 1, 3 ) * rhs2.XFORM( 3, 2 ),
653  // temp.XFORM(1,3)
654  XFORM( 1, 0 ) * rhs2.XFORM( 0, 3 ) + XFORM( 1, 1 ) * rhs2.XFORM( 1, 3 ) + XFORM( 1, 2 ) * rhs2.XFORM( 2, 3 ) +
655  XFORM( 1, 3 ) * rhs2.XFORM( 3, 3 ),
656 
657  // temp.XFORM(2,0)
658  XFORM( 2, 0 ) * rhs2.XFORM( 0, 0 ) + XFORM( 2, 1 ) * rhs2.XFORM( 1, 0 ) + XFORM( 2, 2 ) * rhs2.XFORM( 2, 0 ) +
659  XFORM( 2, 3 ) * rhs2.XFORM( 3, 0 ),
660  // temp.XFORM(2,1)
661  XFORM( 2, 0 ) * rhs2.XFORM( 0, 1 ) + XFORM( 2, 1 ) * rhs2.XFORM( 1, 1 ) + XFORM( 2, 2 ) * rhs2.XFORM( 2, 1 ) +
662  XFORM( 2, 3 ) * rhs2.XFORM( 3, 1 ),
663  // temp.XFORM(2,2)
664  XFORM( 2, 0 ) * rhs2.XFORM( 0, 2 ) + XFORM( 2, 1 ) * rhs2.XFORM( 1, 2 ) + XFORM( 2, 2 ) * rhs2.XFORM( 2, 2 ) +
665  XFORM( 2, 3 ) * rhs2.XFORM( 3, 2 ),
666  // temp.XFORM(2,3)
667  XFORM( 2, 0 ) * rhs2.XFORM( 0, 3 ) + XFORM( 2, 1 ) * rhs2.XFORM( 1, 3 ) + XFORM( 2, 2 ) * rhs2.XFORM( 2, 3 ) +
668  XFORM( 2, 3 ) * rhs2.XFORM( 3, 3 ),
669 
670  // temp.XFORM(3,0)
671  XFORM( 3, 0 ) * rhs2.XFORM( 0, 0 ) + XFORM( 3, 1 ) * rhs2.XFORM( 1, 0 ) + XFORM( 3, 2 ) * rhs2.XFORM( 2, 0 ) +
672  XFORM( 3, 3 ) * rhs2.XFORM( 3, 0 ),
673  // temp.XFORM(3,1)
674  XFORM( 3, 0 ) * rhs2.XFORM( 0, 1 ) + XFORM( 3, 1 ) * rhs2.XFORM( 1, 1 ) + XFORM( 3, 2 ) * rhs2.XFORM( 2, 1 ) +
675  XFORM( 3, 3 ) * rhs2.XFORM( 3, 1 ),
676  // temp.XFORM(3,2)
677  XFORM( 3, 0 ) * rhs2.XFORM( 0, 2 ) + XFORM( 3, 1 ) * rhs2.XFORM( 1, 2 ) + XFORM( 3, 2 ) * rhs2.XFORM( 2, 2 ) +
678  XFORM( 3, 3 ) * rhs2.XFORM( 3, 2 ),
679  // temp.XFORM(3,3)
680  XFORM( 3, 0 ) * rhs2.XFORM( 0, 3 ) + XFORM( 3, 1 ) * rhs2.XFORM( 1, 3 ) + XFORM( 3, 2 ) * rhs2.XFORM( 2, 3 ) +
681  XFORM( 3, 3 ) * rhs2.XFORM( 3, 3 ) );
682 
683  return *this;
684 }

References HomXform(), and XFORM.

◆ operator=()

HomXform & moab::HomXform::operator= ( const HomXform rhs)
inline

Definition at line 556 of file HomXform.hpp.

557 {
558  for( int i = 0; i < 16; i++ )
559  xForm[i] = rhs.xForm[i];
560 
561  return *this;
562 }

References xForm.

◆ operator==()

bool moab::HomXform::operator== ( const HomXform rhs) const
inline

Definition at line 696 of file HomXform.hpp.

697 {
698  return ( xForm[0] == rhs.xForm[0] && xForm[1] == rhs.xForm[1] && xForm[2] == rhs.xForm[2] &&
699  xForm[3] == rhs.xForm[3] && xForm[4] == rhs.xForm[4] && xForm[5] == rhs.xForm[5] &&
700  xForm[6] == rhs.xForm[6] && xForm[7] == rhs.xForm[7] && xForm[8] == rhs.xForm[8] &&
701  xForm[9] == rhs.xForm[9] && xForm[10] == rhs.xForm[10] && xForm[11] == rhs.xForm[11] &&
702  xForm[12] == rhs.xForm[12] && xForm[13] == rhs.xForm[13] && xForm[14] == rhs.xForm[14] &&
703  xForm[15] == rhs.xForm[15] );
704 }

References xForm.

◆ operator[]() [1/2]

int & moab::HomXform::operator[] ( const int &  count)
inline

Definition at line 691 of file HomXform.hpp.

692 {
693  return xForm[count];
694 }

References xForm.

◆ operator[]() [2/2]

int moab::HomXform::operator[] ( const int &  count) const
inline

operators

Definition at line 686 of file HomXform.hpp.

687 {
688  return xForm[count];
689 }

References xForm.

◆ three_pt_xform()

void moab::HomXform::three_pt_xform ( const HomCoord p1,
const HomCoord q1,
const HomCoord p2,
const HomCoord q2,
const HomCoord p3,
const HomCoord q3 
)

compute a transform from three points

Definition at line 33 of file HomXform.cpp.

39 {
40  // pmin and pmax are min and max bounding box corners which are mapped to
41  // qmin and qmax, resp. qmin and qmax are not necessarily min/max corners,
42  // since the mapping can change the orientation of the box in the q reference
43  // frame. Re-interpreting the min/max bounding box corners does not change
44  // the mapping.
45 
46  // change that: base on three points for now (figure out whether we can
47  // just use two later); three points are assumed to define an orthogonal
48  // system such that (p2-p1)%(p3-p1) = 0
49 
50  // use the three point rule to compute the mapping, from Mortensen,
51  // "Geometric Modeling". If p1, p2, p3 and q1, q2, q3 are three points in
52  // the two coordinate systems, the three pt rule is:
53  //
54  // v1 = p2 - p1
55  // v2 = p3 - p1
56  // v3 = v1 x v2
57  // w1-w3 similar, with q1-q3
58  // V = matrix with v1-v3 as rows
59  // W similar, with w1-w3
60  // R = V^-1 * W
61  // t = q1 - p1 * W
62  // Form transform matrix M from R, t
63 
64  // check to see whether unity transform applies
65  if( p1 == q1 && p2 == q2 && p3 == q3 )
66  {
67  *this = HomXform::IDENTITY;
68  return;
69  }
70 
71  // first, construct 3 pts from input
72  HomCoord v1 = p2 - p1;
73  assert( v1.i() != 0 || v1.j() != 0 || v1.k() != 0 );
74  HomCoord v2 = p3 - p1;
75  HomCoord v3 = v1 * v2;
76 
77  if( v3.length_squared() == 0 )
78  {
79  // 1d coordinate system; set one of v2's coordinates such that
80  // it's orthogonal to v1
81  if( v1.i() == 0 )
82  v2.set( 1, 0, 0 );
83  else if( v1.j() == 0 )
84  v2.set( 0, 1, 0 );
85  else if( v1.k() == 0 )
86  v2.set( 0, 0, 1 );
87  else
88  assert( false );
89  v3 = v1 * v2;
90  assert( v3.length_squared() != 0 );
91  }
92  // assert to make sure they're each orthogonal
93  assert( v1 % v2 == 0 && v1 % v3 == 0 && v2 % v3 == 0 );
94  v1.normalize();
95  v2.normalize();
96  v3.normalize();
97  // Make sure h is set to zero here, since it'll mess up things if it's one
98  v1.homCoord[3] = v2.homCoord[3] = v3.homCoord[3] = 0;
99 
100  HomCoord w1 = q2 - q1;
101  assert( w1.i() != 0 || w1.j() != 0 || w1.k() != 0 );
102  HomCoord w2 = q3 - q1;
103  HomCoord w3 = w1 * w2;
104 
105  if( w3.length_squared() == 0 )
106  {
107  // 1d coordinate system; set one of w2's coordinates such that
108  // it's orthogonal to w1
109  if( w1.i() == 0 )
110  w2.set( 1, 0, 0 );
111  else if( w1.j() == 0 )
112  w2.set( 0, 1, 0 );
113  else if( w1.k() == 0 )
114  w2.set( 0, 0, 1 );
115  else
116  assert( false );
117  w3 = w1 * w2;
118  assert( w3.length_squared() != 0 );
119  }
120  // assert to make sure they're each orthogonal
121  assert( w1 % w2 == 0 && w1 % w3 == 0 && w2 % w3 == 0 );
122  w1.normalize();
123  w2.normalize();
124  w3.normalize();
125  // Make sure h is set to zero here, since it'll mess up things if it's one
126  w1.homCoord[3] = w2.homCoord[3] = w3.homCoord[3] = 0;
127 
128  // form v^-1 as transpose (ok for orthogonal vectors); put directly into
129  // transform matrix, since it's eventually going to become R
130  *this = HomXform( v1.i(), v2.i(), v3.i(), 0, v1.j(), v2.j(), v3.j(), 0, v1.k(), v2.k(), v3.k(), 0, 0, 0, 0, 1 );
131 
132  // multiply by w to get R
133  *this *= HomXform( w1.i(), w1.j(), w1.k(), 0, w2.i(), w2.j(), w2.k(), 0, w3.i(), w3.j(), w3.k(), 0, 0, 0, 0, 1 );
134 
135  // compute t and put into last row
136  HomCoord t = q1 - p1 * *this;
137  ( *this ).XFORM( 3, 0 ) = t.i();
138  ( *this ).XFORM( 3, 1 ) = t.j();
139  ( *this ).XFORM( 3, 2 ) = t.k();
140 
141  // M should transform p to q
142  assert( ( q1 == p1 * *this ) && ( q2 == p2 * *this ) && ( q3 == p3 * *this ) );
143 }

References moab::HomCoord::homCoord, HomXform(), moab::HomCoord::i(), IDENTITY, moab::HomCoord::j(), moab::HomCoord::k(), moab::HomCoord::length_squared(), moab::HomCoord::normalize(), and moab::HomCoord::set().

Referenced by moab::ScdElementData::add_vsequence(), and moab::SweptElementData::add_vsequence().

Friends And Related Function Documentation

◆ HomCoord

friend class HomCoord
friend

Definition at line 156 of file HomXform.hpp.

Member Data Documentation

◆ IDENTITY

HomXform moab::HomXform::IDENTITY
static

Definition at line 158 of file HomXform.hpp.

Referenced by three_pt_xform().

◆ xForm

int moab::HomXform::xForm[16]
private

the matrix; don't bother storing the last column, since we assume for now it's always unused

Definition at line 153 of file HomXform.hpp.

Referenced by HomXform(), inverse(), operator!=(), moab::HomCoord::operator*(), moab::HomCoord::operator*=(), operator=(), operator==(), and operator[]().


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