Base: apply clang format
This commit is contained in:
@@ -31,19 +31,22 @@
|
||||
using namespace Base;
|
||||
|
||||
CoordinateSystem::CoordinateSystem()
|
||||
: axis(Vector3d(), Vector3d(0,0,1)), xdir(1,0,0), ydir(0,1,0)
|
||||
{
|
||||
}
|
||||
: axis(Vector3d(), Vector3d(0, 0, 1))
|
||||
, xdir(1, 0, 0)
|
||||
, ydir(0, 1, 0)
|
||||
{}
|
||||
|
||||
CoordinateSystem::~CoordinateSystem() = default;
|
||||
|
||||
void CoordinateSystem::setAxes(const Axis& v, const Vector3d& xd)
|
||||
{
|
||||
if (xd.Sqr() < Base::Vector3d::epsilon())
|
||||
if (xd.Sqr() < Base::Vector3d::epsilon()) {
|
||||
throw Base::ValueError("Direction is null vector");
|
||||
}
|
||||
Vector3d yd = v.getDirection() % xd;
|
||||
if (yd.Sqr() < Base::Vector3d::epsilon())
|
||||
if (yd.Sqr() < Base::Vector3d::epsilon()) {
|
||||
throw Base::ValueError("Direction is parallel to Z direction");
|
||||
}
|
||||
ydir = yd;
|
||||
ydir.Normalize();
|
||||
xdir = ydir % v.getDirection();
|
||||
@@ -56,11 +59,13 @@ void CoordinateSystem::setAxes(const Axis& v, const Vector3d& xd)
|
||||
|
||||
void CoordinateSystem::setAxes(const Vector3d& n, const Vector3d& xd)
|
||||
{
|
||||
if (xd.Sqr() < Base::Vector3d::epsilon())
|
||||
if (xd.Sqr() < Base::Vector3d::epsilon()) {
|
||||
throw Base::ValueError("Direction is null vector");
|
||||
}
|
||||
Vector3d yd = n % xd;
|
||||
if (yd.Sqr() < Base::Vector3d::epsilon())
|
||||
if (yd.Sqr() < Base::Vector3d::epsilon()) {
|
||||
throw Base::ValueError("Direction is parallel to Z direction");
|
||||
}
|
||||
ydir = yd;
|
||||
ydir.Normalize();
|
||||
xdir = ydir % n;
|
||||
@@ -78,8 +83,9 @@ void CoordinateSystem::setAxis(const Axis& v)
|
||||
void CoordinateSystem::setXDirection(const Vector3d& dir)
|
||||
{
|
||||
Vector3d yd = axis.getDirection() % dir;
|
||||
if (yd.Sqr() < Base::Vector3d::epsilon())
|
||||
if (yd.Sqr() < Base::Vector3d::epsilon()) {
|
||||
throw Base::ValueError("Direction is parallel to Z direction");
|
||||
}
|
||||
ydir = yd;
|
||||
ydir.Normalize();
|
||||
xdir = ydir % axis.getDirection();
|
||||
@@ -89,8 +95,9 @@ void CoordinateSystem::setXDirection(const Vector3d& dir)
|
||||
void CoordinateSystem::setYDirection(const Vector3d& dir)
|
||||
{
|
||||
Vector3d xd = dir % axis.getDirection();
|
||||
if (xd.Sqr() < Base::Vector3d::epsilon())
|
||||
if (xd.Sqr() < Base::Vector3d::epsilon()) {
|
||||
throw Base::ValueError("Direction is parallel to Z direction");
|
||||
}
|
||||
xdir = xd;
|
||||
xdir.Normalize();
|
||||
ydir = axis.getDirection() % xdir;
|
||||
@@ -107,18 +114,35 @@ Placement CoordinateSystem::displacement(const CoordinateSystem& cs) const
|
||||
const Base::Vector3d& a = axis.getBase();
|
||||
const Base::Vector3d& zdir = axis.getDirection();
|
||||
Base::Matrix4D At;
|
||||
At[0][0] = xdir.x; At[1][0] = ydir.x; At[2][0] = zdir.x;
|
||||
At[0][1] = xdir.y; At[1][1] = ydir.y; At[2][1] = zdir.y;
|
||||
At[0][2] = xdir.z; At[1][2] = ydir.z; At[2][2] = zdir.z;
|
||||
At[0][0] = xdir.x;
|
||||
At[1][0] = ydir.x;
|
||||
At[2][0] = zdir.x;
|
||||
At[0][1] = xdir.y;
|
||||
At[1][1] = ydir.y;
|
||||
At[2][1] = zdir.y;
|
||||
At[0][2] = xdir.z;
|
||||
At[1][2] = ydir.z;
|
||||
At[2][2] = zdir.z;
|
||||
Base::Vector3d at = At * a;
|
||||
At[0][3] = -at.x; At[1][3] = -at.y; At[2][3] = -at.z;
|
||||
At[0][3] = -at.x;
|
||||
At[1][3] = -at.y;
|
||||
At[2][3] = -at.z;
|
||||
|
||||
const Base::Vector3d& b = cs.axis.getBase();
|
||||
const Base::Vector3d& cszdir = cs.axis.getDirection();
|
||||
Base::Matrix4D B;
|
||||
B[0][0] = cs.xdir.x; B[0][1] = cs.ydir.x; B[0][2] = cszdir.x; B[0][3] = b.x;
|
||||
B[1][0] = cs.xdir.y; B[1][1] = cs.ydir.y; B[1][2] = cszdir.y; B[1][3] = b.y;
|
||||
B[2][0] = cs.xdir.z; B[2][1] = cs.ydir.z; B[2][2] = cszdir.z; B[2][3] = b.z;
|
||||
B[0][0] = cs.xdir.x;
|
||||
B[0][1] = cs.ydir.x;
|
||||
B[0][2] = cszdir.x;
|
||||
B[0][3] = b.x;
|
||||
B[1][0] = cs.xdir.y;
|
||||
B[1][1] = cs.ydir.y;
|
||||
B[1][2] = cszdir.y;
|
||||
B[1][3] = b.y;
|
||||
B[2][0] = cs.xdir.z;
|
||||
B[2][1] = cs.ydir.z;
|
||||
B[2][2] = cszdir.z;
|
||||
B[2][3] = b.z;
|
||||
|
||||
Placement PAt(At);
|
||||
Placement PB(B);
|
||||
@@ -149,11 +173,11 @@ void CoordinateSystem::transform(const Rotation& r)
|
||||
|
||||
void CoordinateSystem::setPlacement(const Placement& p)
|
||||
{
|
||||
Vector3d zdir(0,0,1);
|
||||
Vector3d zdir(0, 0, 1);
|
||||
p.getRotation().multVec(zdir, zdir);
|
||||
axis.setBase(p.getPosition());
|
||||
axis.setDirection(zdir);
|
||||
|
||||
p.getRotation().multVec(Vector3d(1,0,0), this->xdir);
|
||||
p.getRotation().multVec(Vector3d(0,1,0), this->ydir);
|
||||
p.getRotation().multVec(Vector3d(1, 0, 0), this->xdir);
|
||||
p.getRotation().multVec(Vector3d(0, 1, 0), this->ydir);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user