CFx SDK Documentation 2024 SP0
Loading...
Searching...
No Matches
AECECS.h
Go to the documentation of this file.
1
2// Copyright (C) 2002-2022, Open Design Alliance (the "Alliance").
3// All rights reserved.
4//
5// This software and its documentation and related materials are owned by
6// the Alliance. The software may only be incorporated into application
7// programs owned by members of the Alliance, subject to a signed
8// Membership Agreement and Supplemental Software License Agreement with the
9// Alliance. The structure and organization of this software are the valuable
10// trade secrets of the Alliance and its suppliers. The software is also
11// protected by copyright law and international treaty provisions. Application
12// programs incorporating this software must include the following statement
13// with their copyright notices:
14//
15// This application incorporates Open Design Alliance software pursuant to a
16// license agreement with Open Design Alliance.
17// Open Design Alliance Copyright (C) 2002-2022 by Open Design Alliance.
18// All rights reserved.
19//
20// By use of this software, its documentation or related materials, you
21// acknowledge and accept the above terms.
23
24#ifndef __AECECS_H__
25#define __AECECS_H__
26
27#include "AECBase.h"
28#include "Ge/GeGbl.h"
29#include "Ge/GeMatrix2d.h"
30#include "Ge/GePoint3d.h"
31#include "Ge/GeMatrix3d.h"
32
33class OdGeLine3d;
34class OdGeVector3d;
35class OdGePlane;
36class OdGeTol;
37class OdGeScale3d;
38
39
50class AECBASE_API AECECS
51{
52public:
53 AECECS();
54 AECECS( const OdGeMatrix3d& m );
55 AECECS( const OdGePoint3d& origin,
56 const OdGeVector3d& xAxis,
57 const OdGeVector3d& yAxis,
58 const OdGeVector3d& zAxis );
59
60 static const AECECS kIdentity;
61
63
67 void validateZero( const OdGeTol& tol = OdGeContext::gTol );
68
69 // Multiplication.
70 //
71
75 AECECS operator * ( const AECECS& matrix ) const;
76
81 AECECS& operator *= ( const AECECS& matrix );
88 AECECS& preMultBy( const AECECS& leftSide );
89
96 AECECS& postMultBy( const AECECS& rightSide );
97
105 AECECS& setToProduct( const AECECS& m1, const AECECS& m2);
106
107 // Multiplicative inverse.
108 //
109
114 AECECS& invert();
115
116
117 // Test if it is a singular matrix. A singular matrix is not invertible.
118 //
119
127 bool isSingular( const OdGeTol& tol = OdGeContext::gTol ) const;
128
129 // Tests for equivalence using the infinity norm.
130 //
131
132 bool operator == ( const AECECS& matrix ) const { return isEqualTo(matrix); }
133 bool operator != ( const AECECS& matrix) const { return !isEqualTo(matrix); }
134
142 bool isEqualTo( const AECECS& matrix, const OdGeTol& tol = OdGeContext::gTol ) const;
143
152
161
165 double det() const;
166
167
173 AECECS& setTranslation( const OdGeVector3d& vect );
174
175
176 // Set/get coordinate system
177 //
178
190 AECECS& setCoordSystem(
191 const OdGePoint3d& origin,
192 const OdGeVector3d& xAxis,
193 const OdGeVector3d& yAxis,
194 const OdGeVector3d& zAxis);
195
206 OdGePoint3d& origin,
207 OdGeVector3d& xAxis,
208 OdGeVector3d& yAxis,
209 OdGeVector3d& zAxis) const;
210
215 const OdGePoint3d& getCsOrigin( ) const;
216
221 const OdGeVector3d& getCsXAxis( ) const;
222
227 const OdGeVector3d& getCsYAxis( ) const;
232 const OdGeVector3d& getCsZAxis( ) const;
233
234 // Set the matrix to be a specified transformation
235 //
236
244 AECECS& setToTranslation( const OdGeVector3d& vect );
245
255 AECECS& setToRotation( double angle, const OdGeVector3d& axis,
256 const OdGePoint3d& center = OdGePoint3d::kOrigin );
257
267 const OdGePoint3d& center = OdGePoint3d::kOrigin );
269 const OdGePoint3d& center = OdGePoint3d::kOrigin );
270
280 AECECS& setToMirroring( const OdGePlane& mirrorPlane );
281 AECECS& setToMirroring( const OdGePoint3d& mirrorPoint );
282 AECECS& setToMirroring( const OdGeLine3d& mirrorLine );
283
293 AECECS& setToProjection(
294 const OdGePlane& projectionPlane,
295 const OdGeVector3d& projectDir);
296
314 const OdGePoint3d& fromOrigin,
315 const OdGeVector3d& fromXAxis,
316 const OdGeVector3d& fromYAxis,
317 const OdGeVector3d& fromZAxis,
318 const OdGePoint3d& toOrigin,
319 const OdGeVector3d& toXAxis,
320 const OdGeVector3d& toYAxis,
321 const OdGeVector3d& toZAxis);
322
323
334 AECECS& setToWorldToPlane( const OdGeVector3d& normal );
336
349
350 // Similar to above, but creates matrix on the stack.
351 //
352
358 static AECECS translation( const OdGeVector3d& vect );
359 const OdGeVector3d& translation() const;
360
370 static AECECS rotation(
371 double angle, const OdGeVector3d& axis,
372 const OdGePoint3d& center = OdGePoint3d::kOrigin );
373
382 static AECECS scaling( double scale,
383 const OdGePoint3d& center = OdGePoint3d::kOrigin );
384 static AECECS scaling( const OdGeScale3d& scale,
385 const OdGePoint3d& center = OdGePoint3d::kOrigin );
386
387
397 static AECECS mirroring( const OdGePlane& mirrorPlane );
398 static AECECS mirroring( const OdGePoint3d& mirrorPoint );
399 static AECECS mirroring( const OdGeLine3d& mirrorLine );
400
410 const OdGePlane& projectionPlane,
411 const OdGeVector3d& projectDir);
412
429 const OdGePoint3d& fromOrigin,
430 const OdGeVector3d& fromXAxis,
431 const OdGeVector3d& fromYAxis,
432 const OdGeVector3d& fromZAxis,
433 const OdGePoint3d& toOrigin,
434 const OdGeVector3d& toXAxis,
435 const OdGeVector3d& toYAxis,
436 const OdGeVector3d& toZAxis);
437
448 static AECECS worldToPlane( const OdGeVector3d& normal );
449 static AECECS worldToPlane( const OdGePlane& plane );
450
461 static AECECS planeToWorld( const OdGeVector3d& normal );
462 static AECECS planeToWorld( const OdGePlane& plane );
463
482 double scale() const;
483
487 double norm() const;
488
499 OdGeMatrix2d convertToLocal( OdGeVector3d& normal, double& elevation ) const;
500
502
510 AECECS inverse( ) const;
511
512 bool inverse( AECECS& inverseMatrix, double tol ) const;
513
514 // For convenient access to the data.
515 //
516
542 void geMatrix( OdGeMatrix3d& result ) const;
543 operator OdGeMatrix3d () const;
544 AECECS& operator = (const OdGeMatrix3d& m );
545
546 // The components of the matrix.
547 //
552};
553
554AECBASE_API OdGePoint3d operator * ( const AECECS& matrix, const OdGePoint3d& point );
555AECBASE_API OdGeVector3d operator * ( const AECECS& matrix, const OdGeVector3d& vector );
556
558 : m_xAxis( OdGeVector3d::kXAxis )
559 , m_yAxis( OdGeVector3d::kYAxis )
560 , m_zAxis( OdGeVector3d::kZAxis )
561{
562}
563
564inline AECECS::AECECS( const OdGePoint3d& origin,
565 const OdGeVector3d& xAxis,
566 const OdGeVector3d& yAxis,
567 const OdGeVector3d& zAxis )
568 : m_origin( origin )
569 , m_xAxis( xAxis )
570 , m_yAxis( yAxis )
571 , m_zAxis( zAxis )
572{
573}
574
575inline AECECS::AECECS( const OdGeMatrix3d& m ) {
577 ODA_ASSERT(//Value of AECECS is not equivalint to value OdGeMatrix3d.
578 OdZero(m[3][0], 1e-100) &&
579 OdZero(m[3][1], 1e-100) &&
580 OdZero(m[3][2], 1e-100) &&
581 OdEqual( m[3][3], 1.0, 1e-100)
582 );
583}
584
585inline const OdGePoint3d& AECECS::getCsOrigin() const { return m_origin; }
586inline const OdGeVector3d& AECECS::getCsXAxis() const { return m_xAxis; }
587inline const OdGeVector3d& AECECS::getCsYAxis() const { return m_yAxis; }
588inline const OdGeVector3d& AECECS::getCsZAxis() const { return m_zAxis; }
589
591 const OdGePoint3d& origin,
592 const OdGeVector3d& xAxis,
593 const OdGeVector3d& yAxis,
594 const OdGeVector3d& zAxis)
595{
596 m_origin = origin;
597 m_xAxis = xAxis;
598 m_yAxis = yAxis;
599 m_zAxis = zAxis;
600 return *this;
601}
602
603inline void AECECS::geMatrix( OdGeMatrix3d& result ) const {
605}
606
607inline AECECS::operator OdGeMatrix3d () const {
608 OdGeMatrix3d result;
609 geMatrix( result );
610 return result;
611}
612
615 return *this;
616}
617
618inline AECECS& AECECS::postMultBy( const AECECS& right ) {
619 return setToProduct( *this, right );
620}
621
622inline AECECS& AECECS::preMultBy( const AECECS& left ) {
623 return setToProduct( left, *this );
624}
625
626inline AECECS AECECS::operator * ( const AECECS& right ) const {
627 return AECECS().setToProduct( *this, right );
628}
629
630inline AECECS& AECECS::operator *= ( const AECECS& right ) {
631 return setToProduct( *this, right );
632}
633
635 return ( *this = inverse() );
636}
637
638inline AECECS AECECS::inverse() const {
639 AECECS res;
640 if(!inverse(res, 1.e-300)) {
642 }
643 return res;
644}
645
646inline const OdGeVector3d& AECECS::translation() const {
647 return getCsOrigin().asVector();
648}
649
651 m_origin = (const OdGePoint3d&)vec;
652 return *this;
653}
654
657 setTranslation(vec);
658 return *this;
659}
660
661inline AECECS& AECECS::setToProjection( const OdGePlane& projectionPlane,
662 const OdGeVector3d& projectDir ) {
663 return *this = OdGeMatrix3d::projection( projectionPlane, projectDir );
664}
665
667 setToPlaneToWorld( normal );
668 return invert();
669}
670
671inline void AECECS::validateZero( const OdGeTol& tol ) {
672 OdGeMatrix3d m( *this );
673 m.validateZero( tol );
674 *this = m;
675}
676
678 return AECECS().setToTranslation(vec);
679}
680
682 double angle, const OdGeVector3d& axis, const OdGePoint3d& center)
683{
684 return AECECS().setToRotation(angle, axis, center);
685}
686
687inline AECECS AECECS::scaling(double scaleAll, const OdGePoint3d& center) {
688 return AECECS().setToScaling( scaleAll, center );
689}
690
691inline AECECS AECECS::scaling(const OdGeScale3d& scale, const OdGePoint3d& center) {
692 return AECECS().setToScaling(scale, center);
693}
694
696 return *this = mirroring(pln);
697}
698
699inline AECECS& AECECS::setToMirroring( const OdGePoint3d& mirrorPoint ) {
700 return *this = mirroring(mirrorPoint);
701}
702
703inline AECECS& AECECS::setToMirroring( const OdGeLine3d& mirrorLine ) {
704 return *this = mirroring(mirrorLine);
705}
706
707#endif //__AECECS_H__
AECBASE_API OdGePoint3d operator*(const AECECS &matrix, const OdGePoint3d &point)
#define ODA_ASSERT(exp)
Definition: DebugStuff.h:57
tol
Definition: DimVarDefs.h:2287
scale
Definition: DimVarDefs.h:1684
@ eDegenerateGeometry
void GE_ERROR(OdResult res)
Definition: GeGbl.h:447
bool operator!=(T left, const OdGiVariant::EnumType right)
Definition: GiVariant.h:403
bool operator==(T left, const OdGiVariant::EnumType right)
Definition: GiVariant.h:397
bool OdEqual(double x, double y, double tol=1.e-10)
Definition: OdaDefs.h:542
bool OdZero(double x, double tol=1.e-10)
Definition: OdaDefs.h:532
Definition: AECECS.h:51
AECECS & setToProduct(const AECECS &m1, const AECECS &m2)
void validateZero(const OdGeTol &tol=OdGeContext::gTol)
Definition: AECECS.h:671
const OdGeVector3d & getCsYAxis() const
Definition: AECECS.h:587
AECECS & setToAlignCoordSys(const OdGePoint3d &fromOrigin, const OdGeVector3d &fromXAxis, const OdGeVector3d &fromYAxis, const OdGeVector3d &fromZAxis, const OdGePoint3d &toOrigin, const OdGeVector3d &toXAxis, const OdGeVector3d &toYAxis, const OdGeVector3d &toZAxis)
AECECS & setTranslation(const OdGeVector3d &vect)
Definition: AECECS.h:650
const OdGePoint3d & getCsOrigin() const
Definition: AECECS.h:585
void geMatrix(OdGeMatrix3d &result) const
Definition: AECECS.h:603
AECECS & setToWorldToPlane(const OdGeVector3d &normal)
Definition: AECECS.h:666
bool isUniScaledOrtho(const OdGeTol &tol=OdGeContext::gTol) const
static AECECS projection(const OdGePlane &projectionPlane, const OdGeVector3d &projectDir)
AECECS & operator*=(const AECECS &matrix)
Definition: AECECS.h:630
OdGeVector3d m_xAxis
Definition: AECECS.h:549
static AECECS worldToPlane(const OdGeVector3d &normal)
AECECS & setToScaling(double scale, const OdGePoint3d &center=OdGePoint3d::kOrigin)
AECECS & setToProjection(const OdGePlane &projectionPlane, const OdGeVector3d &projectDir)
Definition: AECECS.h:661
AECECS & setCoordSystem(const OdGePoint3d &origin, const OdGeVector3d &xAxis, const OdGeVector3d &yAxis, const OdGeVector3d &zAxis)
Definition: AECECS.h:590
static AECECS rotation(double angle, const OdGeVector3d &axis, const OdGePoint3d &center=OdGePoint3d::kOrigin)
Definition: AECECS.h:681
OdGeVector3d m_zAxis
Definition: AECECS.h:551
static AECECS scaling(double scale, const OdGePoint3d &center=OdGePoint3d::kOrigin)
Definition: AECECS.h:687
double norm() const
static AECECS worldToPlane(const OdGePlane &plane)
AECECS & setToPlaneToWorld(const OdGeVector3d &normal)
static AECECS mirroring(const OdGePlane &mirrorPlane)
OdGeMatrix2d convertToLocalXY() const
bool isSingular(const OdGeTol &tol=OdGeContext::gTol) const
AECECS & preMultBy(const AECECS &leftSide)
Definition: AECECS.h:622
AECECS & operator=(const OdGeMatrix3d &m)
Definition: AECECS.h:613
const OdGeVector3d & getCsXAxis() const
Definition: AECECS.h:586
static const AECECS kIdentity
Definition: AECECS.h:60
static AECECS alignCoordSys(const OdGePoint3d &fromOrigin, const OdGeVector3d &fromXAxis, const OdGeVector3d &fromYAxis, const OdGeVector3d &fromZAxis, const OdGePoint3d &toOrigin, const OdGeVector3d &toXAxis, const OdGeVector3d &toYAxis, const OdGeVector3d &toZAxis)
OdGeVector3d m_yAxis
Definition: AECECS.h:550
OdGePoint3d m_origin
Definition: AECECS.h:548
AECECS operator*(const AECECS &matrix) const
Definition: AECECS.h:626
AECECS & setToRotation(double angle, const OdGeVector3d &axis, const OdGePoint3d &center=OdGePoint3d::kOrigin)
bool inverse(AECECS &inverseMatrix, double tol) const
void getCoordSystem(OdGePoint3d &origin, OdGeVector3d &xAxis, OdGeVector3d &yAxis, OdGeVector3d &zAxis) const
AECECS & setToMirroring(const OdGePlane &mirrorPlane)
Definition: AECECS.h:695
static AECECS planeToWorld(const OdGePlane &plane)
AECECS & setToScaling(const OdGeScale3d &scale, const OdGePoint3d &center=OdGePoint3d::kOrigin)
AECECS()
Definition: AECECS.h:557
static AECECS mirroring(const OdGeLine3d &mirrorLine)
static AECECS mirroring(const OdGePoint3d &mirrorPoint)
bool isScaledOrtho(const OdGeTol &tol=OdGeContext::gTol) const
AECECS & setToPlaneToWorld(const OdGePlane &plane)
static AECECS planeToWorld(const OdGeVector3d &normal)
OdGeMatrix2d convertToLocal(OdGeVector3d &normal, double &elevation) const
const OdGeVector3d & getCsZAxis() const
Definition: AECECS.h:588
AECECS & invert()
Definition: AECECS.h:634
AECECS inverse() const
Definition: AECECS.h:638
AECECS & setToWorldToPlane(const OdGePlane &plane)
AECECS & postMultBy(const AECECS &rightSide)
Definition: AECECS.h:618
AECECS & setToIdentity()
double det() const
bool isEqualTo(const AECECS &matrix, const OdGeTol &tol=OdGeContext::gTol) const
const OdGeVector3d & translation() const
Definition: AECECS.h:646
AECECS & setToTranslation(const OdGeVector3d &vect)
Definition: AECECS.h:655
double scale() const
void getCoordSystem(OdGePoint3d &origin, OdGeVector3d &xAxis, OdGeVector3d &yAxis, OdGeVector3d &zAxis) const
OdGeMatrix3d & setCoordSystem(const OdGePoint3d &origin, const OdGeVector3d &xAxis, const OdGeVector3d &yAxis, const OdGeVector3d &zAxis)
void validateZero(const OdGeTol &tol=OdGeContext::gTol)
static OdGeMatrix3d projection(const OdGePlane &projectionPlane, const OdGeVector3d &projectDir)
const OdGeVector3d & asVector() const
Definition: GePoint3d.h:549
static GE_STATIC_EXPORT const OdGePoint3d kOrigin
Definition: GePoint3d.h:106
Definition: GeTol.h:49
GLboolean invert
Definition: gles2_ext.h:109
static GE_STATIC_EXPORT OdGeTol gTol
Definition: GeGbl.h:65