mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-09-03 14:10:33 +03:00
274 lines
8.0 KiB
Plaintext
Executable File
274 lines
8.0 KiB
Plaintext
Executable File
// Copyright (c) 1995-1999 Matra Datavision
|
|
// Copyright (c) 1999-2012 OPEN CASCADE SAS
|
|
//
|
|
// The content of this file is subject to the Open CASCADE Technology Public
|
|
// License Version 6.5 (the "License"). You may not use the content of this file
|
|
// except in compliance with the License. Please obtain a copy of the License
|
|
// at http://www.opencascade.org and read it completely before using this file.
|
|
//
|
|
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
|
|
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
|
|
//
|
|
// The Original Code and all software distributed under the License is
|
|
// distributed on an "AS IS" basis, without warranty of any kind, and the
|
|
// Initial Developer hereby disclaims all such warranties, including without
|
|
// limitation, any warranties of merchantability, fitness for a particular
|
|
// purpose or non-infringement. Please see the License for the specific terms
|
|
// and conditions governing the rights and limitations under the License.
|
|
|
|
|
|
#include <gp.hxx>
|
|
#include <Standard_OutOfRange.hxx>
|
|
|
|
#define Mat2d00 ((Standard_Real*)M)[0]
|
|
#define Mat2d01 ((Standard_Real*)M)[1]
|
|
#define Mat2d10 ((Standard_Real*)M)[2]
|
|
#define Mat2d11 ((Standard_Real*)M)[3]
|
|
|
|
#define Nat2d00 ((Standard_Real*)N)[0]
|
|
#define Nat2d01 ((Standard_Real*)N)[1]
|
|
#define Nat2d10 ((Standard_Real*)N)[2]
|
|
#define Nat2d11 ((Standard_Real*)N)[3]
|
|
|
|
#define Oat2d00 ((Standard_Real*)O)[0]
|
|
#define Oat2d01 ((Standard_Real*)O)[1]
|
|
#define Oat2d10 ((Standard_Real*)O)[2]
|
|
#define Oat2d11 ((Standard_Real*)O)[3]
|
|
|
|
inline gp_Mat2d::gp_Mat2d ()
|
|
{
|
|
const Standard_Address M = (Standard_Address)&(matrix[0][0]);
|
|
Mat2d00 = Mat2d01 = Mat2d10 = Mat2d11 = 0.0;
|
|
}
|
|
|
|
inline void gp_Mat2d::SetDiagonal (const Standard_Real X1,
|
|
const Standard_Real X2)
|
|
{
|
|
const Standard_Address M = (Standard_Address)&(matrix[0][0]);
|
|
Mat2d00 = X1; Mat2d11 = X2;
|
|
}
|
|
|
|
inline void gp_Mat2d::SetIdentity ()
|
|
{
|
|
const Standard_Address M = (Standard_Address)&(matrix[0][0]);
|
|
Mat2d00 = Mat2d11 = 1.0;
|
|
Mat2d01 = Mat2d10 = 0.0;
|
|
}
|
|
|
|
inline void gp_Mat2d::SetRotation (const Standard_Real Ang)
|
|
{
|
|
const Standard_Address M = (Standard_Address)&(matrix[0][0]);
|
|
Standard_Real SinA = sin(Ang);
|
|
Standard_Real CosA = cos(Ang);
|
|
Mat2d00 = Mat2d11 = CosA;
|
|
Mat2d01 = -SinA;
|
|
Mat2d10 = SinA;
|
|
}
|
|
|
|
inline void gp_Mat2d::SetScale (const Standard_Real S)
|
|
{
|
|
const Standard_Address M = (Standard_Address)&(matrix[0][0]);
|
|
Mat2d00 = Mat2d11 = S;
|
|
Mat2d01 = Mat2d10 = 0.0;
|
|
}
|
|
|
|
inline void gp_Mat2d::SetValue (const Standard_Integer Row,
|
|
const Standard_Integer Col,
|
|
const Standard_Real Value)
|
|
{
|
|
Standard_OutOfRange_Raise_if
|
|
(Row < 1 || Row > 2 || Col < 1 || Col > 2, " ");
|
|
matrix[Row-1][Col-1] = Value;
|
|
}
|
|
|
|
inline Standard_Real gp_Mat2d::Determinant () const
|
|
{
|
|
const Standard_Address M = (Standard_Address)&(matrix[0][0]);
|
|
return Mat2d00 * Mat2d11 - Mat2d10 * Mat2d01;
|
|
}
|
|
|
|
inline const Standard_Real& gp_Mat2d::Value (const Standard_Integer Row,
|
|
const Standard_Integer Col) const
|
|
{
|
|
Standard_OutOfRange_Raise_if
|
|
(Row < 1 || Row > 2 || Col < 1 || Col > 2, " ");
|
|
return matrix[Row-1][Col-1];
|
|
}
|
|
|
|
inline Standard_Real&
|
|
gp_Mat2d::ChangeValue (const Standard_Integer Row,
|
|
const Standard_Integer Col)
|
|
{
|
|
Standard_OutOfRange_Raise_if
|
|
(Row < 1 || Row > 2 || Col < 1 || Col > 2, " ");
|
|
return matrix[Row-1][Col-1];
|
|
}
|
|
|
|
inline Standard_Boolean gp_Mat2d::IsSingular () const
|
|
{
|
|
Standard_Real det = Determinant();
|
|
if (det < 0) det = - det;
|
|
return det <= gp::Resolution();
|
|
}
|
|
|
|
inline void gp_Mat2d::Add (const gp_Mat2d& Other)
|
|
{
|
|
const Standard_Address M = (Standard_Address)&( matrix[0][0]);
|
|
const Standard_Address O = (Standard_Address)&(Other.matrix[0][0]);
|
|
Mat2d00 += Oat2d00;
|
|
Mat2d01 += Oat2d01;
|
|
Mat2d10 += Oat2d10;
|
|
Mat2d11 += Oat2d11;
|
|
}
|
|
|
|
inline gp_Mat2d gp_Mat2d::Added (const gp_Mat2d& Other) const
|
|
{
|
|
gp_Mat2d NewMat2d;
|
|
const Standard_Address M = (Standard_Address)&( matrix[0][0]);
|
|
const Standard_Address N = (Standard_Address)&(NewMat2d.matrix[0][0]);
|
|
const Standard_Address O = (Standard_Address)&(Other .matrix[0][0]);
|
|
Nat2d00 = Mat2d00 + Oat2d00;
|
|
Nat2d01 = Mat2d01 + Oat2d01;
|
|
Nat2d10 = Mat2d10 + Oat2d10;
|
|
Nat2d11 = Mat2d11 + Oat2d11;
|
|
return NewMat2d;
|
|
}
|
|
|
|
inline void gp_Mat2d::Divide (const Standard_Real Scalar)
|
|
{
|
|
const Standard_Address M = (Standard_Address)&(matrix[0][0]);
|
|
Mat2d00 /= Scalar;
|
|
Mat2d01 /= Scalar;
|
|
Mat2d10 /= Scalar;
|
|
Mat2d11 /= Scalar;
|
|
}
|
|
|
|
inline gp_Mat2d gp_Mat2d::Divided (const Standard_Real Scalar) const
|
|
{
|
|
gp_Mat2d NewMat2d;
|
|
const Standard_Address M = (Standard_Address)&( matrix[0][0]);
|
|
const Standard_Address N = (Standard_Address)&(NewMat2d.matrix[0][0]);
|
|
Nat2d00 = Mat2d00 / Scalar;
|
|
Nat2d01 = Mat2d01 / Scalar;
|
|
Nat2d10 = Mat2d10 / Scalar;
|
|
Nat2d11 = Mat2d11 / Scalar;
|
|
return NewMat2d;
|
|
}
|
|
|
|
inline gp_Mat2d gp_Mat2d::Inverted () const
|
|
{
|
|
gp_Mat2d NewMat = *this;
|
|
NewMat.Invert();
|
|
return NewMat;
|
|
}
|
|
|
|
inline gp_Mat2d gp_Mat2d::Multiplied (const gp_Mat2d& Other) const
|
|
{
|
|
gp_Mat2d NewMat2d = *this;
|
|
NewMat2d.Multiply(Other);
|
|
return NewMat2d;
|
|
}
|
|
|
|
inline void gp_Mat2d::Multiply (const gp_Mat2d& Other)
|
|
{
|
|
Standard_Real T00,T10;
|
|
const Standard_Address M = (Standard_Address)&( matrix[0][0]);
|
|
const Standard_Address O = (Standard_Address)&(Other.matrix[0][0]);
|
|
T00 = Mat2d00 * Oat2d00 + Mat2d01 * Oat2d10;
|
|
T10 = Mat2d10 * Oat2d00 + Mat2d11 * Oat2d10;
|
|
Mat2d01 = Mat2d00 * Oat2d01 + Mat2d01 * Oat2d11;
|
|
Mat2d11 = Mat2d10 * Oat2d01 + Mat2d11 * Oat2d11;
|
|
Mat2d00 = T00;
|
|
Mat2d10 = T10;
|
|
}
|
|
|
|
inline void gp_Mat2d::PreMultiply (const gp_Mat2d& Other)
|
|
{
|
|
Standard_Real T00,T01;
|
|
const Standard_Address M = (Standard_Address)&( matrix[0][0]);
|
|
const Standard_Address O = (Standard_Address)&(Other.matrix[0][0]);
|
|
T00 = Oat2d00 * Mat2d00 + Oat2d01 * Mat2d10;
|
|
Mat2d10 = Oat2d10 * Mat2d00 + Oat2d11 * Mat2d10;
|
|
T01 = Oat2d00 * Mat2d01 + Oat2d01 * Mat2d11;
|
|
Mat2d11 = Oat2d10 * Mat2d01 + Oat2d11 * Mat2d11;
|
|
Mat2d00 = T00;
|
|
Mat2d01 = T01;
|
|
}
|
|
|
|
inline gp_Mat2d gp_Mat2d::Multiplied (const Standard_Real Scalar) const
|
|
{
|
|
gp_Mat2d NewMat2d;
|
|
const Standard_Address M = (Standard_Address)&( matrix[0][0]);
|
|
const Standard_Address N = (Standard_Address)&(NewMat2d.matrix[0][0]);
|
|
Nat2d00 = Mat2d00 * Scalar;
|
|
Nat2d01 = Mat2d01 * Scalar;
|
|
Nat2d10 = Mat2d10 * Scalar;
|
|
Nat2d11 = Mat2d11 * Scalar;
|
|
return NewMat2d;
|
|
}
|
|
|
|
inline void gp_Mat2d::Multiply (const Standard_Real Scalar)
|
|
{
|
|
const Standard_Address M = (Standard_Address)&(matrix[0][0]);
|
|
Mat2d00 *= Scalar;
|
|
Mat2d01 *= Scalar;
|
|
Mat2d10 *= Scalar;
|
|
Mat2d11 *= Scalar;
|
|
}
|
|
|
|
inline gp_Mat2d gp_Mat2d::Powered (const Standard_Integer N) const
|
|
{
|
|
gp_Mat2d Mat2dN = *this;
|
|
Mat2dN.Power (N);
|
|
return Mat2dN;
|
|
}
|
|
|
|
inline void gp_Mat2d::Subtract (const gp_Mat2d& Other)
|
|
{
|
|
const Standard_Address M = (Standard_Address)&( matrix[0][0]);
|
|
const Standard_Address O = (Standard_Address)&(Other.matrix[0][0]);
|
|
Mat2d00 -= Oat2d00;
|
|
Mat2d01 -= Oat2d01;
|
|
Mat2d10 -= Oat2d10;
|
|
Mat2d11 -= Oat2d11;
|
|
}
|
|
|
|
inline gp_Mat2d gp_Mat2d::Subtracted (const gp_Mat2d& Other) const
|
|
{
|
|
gp_Mat2d NewMat2d;
|
|
const Standard_Address M = (Standard_Address)&( matrix[0][0]);
|
|
const Standard_Address N = (Standard_Address)&(NewMat2d.matrix[0][0]);
|
|
const Standard_Address O = (Standard_Address)&(Other .matrix[0][0]);
|
|
Nat2d00 = Mat2d00 - Oat2d00;
|
|
Nat2d01 = Mat2d01 - Oat2d01;
|
|
Nat2d10 = Mat2d10 - Oat2d10;
|
|
Nat2d11 = Mat2d11 - Oat2d11;
|
|
return NewMat2d;
|
|
}
|
|
|
|
inline void gp_Mat2d::Transpose ()
|
|
{
|
|
const Standard_Address M = (Standard_Address)&(matrix[0][0]);
|
|
Standard_Real Temp;
|
|
Temp = Mat2d01;
|
|
Mat2d01 = Mat2d10;
|
|
Mat2d10 = Temp;
|
|
}
|
|
|
|
inline gp_Mat2d gp_Mat2d::Transposed () const
|
|
{
|
|
gp_Mat2d NewMat2d;
|
|
const Standard_Address M = (Standard_Address)&( matrix[0][0]);
|
|
const Standard_Address N = (Standard_Address)&(NewMat2d.matrix[0][0]);
|
|
Nat2d10 = Mat2d01;
|
|
Nat2d01 = Mat2d10;
|
|
Nat2d00 = Mat2d00;
|
|
Nat2d11 = Mat2d11;
|
|
return NewMat2d;
|
|
}
|
|
|
|
inline gp_Mat2d operator* (const Standard_Real Scalar,
|
|
const gp_Mat2d& Mat2D)
|
|
{ return Mat2D.Multiplied (Scalar); }
|
|
|