AMCAX Kernel 1.0.0.0
Loading...
Searching...
No Matches
Applying Multiple Transformations of the Same Type

Overview

This tutorial demonstrates how to apply multiple transformations of the same type in Transformation3, ensuring each transformation takes effect.

Method

First, let's examine an incorrect approach. In the following code, only the third SetRotation is effective, while the first two have no impact:

//Make box
AMCAX::MakeBox mkbox = AMCAX::MakeBox(AMCAX::Point3(0., 0., 0.), AMCAX::Point3(1., 2., 3.));
AMCAX::TopoShape shape = mkbox.Shape();
//SetRotation
//Get a shape with a transformation
shape = AMCAX::TransformShape(shape, trsf);
//Write
AMCAX::STEP::STEPTool::Write(shape, "./test_box1.step");
static AMCAX_API const Axis3 & OZ() noexcept
Get the z-axis in 3D, including the origin and the z-direction.
static AMCAX_API const Axis3 & OX() noexcept
Get the x-axis in 3D, including the origin and the x-direction.
static AMCAX_API const Axis3 & OY() noexcept
Get the y-axis in 3D, including the origin and the y-direction.
Class of making a box.
Definition MakeBox.hpp:20
virtual AMCAX_API const TopoShape & Shape()
Get the resulting shape.
static AMCAX_API bool Write(const AMCAX::TopoShape &s, std::ostream &os)
Write a TopoShape to a stream in STEP format.
Base class of shape, containing an underlying shape with a location and an orientation.
Definition TopoShape.hpp:15
Class of transforming a shape.
Definition TransformShape.hpp:12
void SetRotation(const PointT< OtherScalar, DIM > &point, const OtherScalar2 &angle) noexcept
Set the transformation as rotation around a point with an angle in 2D.
Definition TransformationT.hpp:138
constexpr double pi
Mathematical constant Pi, ratio of a circle's circumference to its diameter.
Definition Constants.hpp:42
TransformationT< double, 3 > Transformation3
3D transformation
Definition TransformationT.hpp:1115
PointT< double, 3 > Point3
3D point
Definition PointT.hpp:459

If you want all three SetRotation operations to take effect, you can achieve this through the following methods:

One TransformShape: Right-Multiplication Method

//Make box
AMCAX::MakeBox mkbox = AMCAX::MakeBox(AMCAX::Point3(0., 0., 0.), AMCAX::Point3(1., 2., 3.));
AMCAX::TopoShape shape = mkbox.Shape();
//SetRotation
finalTrsf = trsf3 * trsf2 * trsf1;
//Get a shape with a transformation
shape = AMCAX::TransformShape(shape, finalTrsf);
//Write
AMCAX::STEP::STEPTool::Write(shape, "./test_box3.step");

One TransformShape: Left-Multiplication Method

//Make box
AMCAX::MakeBox mkbox = AMCAX::MakeBox(AMCAX::Point3(0., 0., 0.), AMCAX::Point3(1., 2., 3.));
AMCAX::TopoShape shape = mkbox.Shape();
//SetRotation
finalTrsf = trsf1.LeftMultiplied(trsf2).LeftMultiplied(trsf3);
//Get a shape with a transformation
shape = AMCAX::TransformShape(shape, finalTrsf);
//Write
AMCAX::STEP::STEPTool::Write(shape, "./test_box4.step");
constexpr TransformationT LeftMultiplied(const TransformationT< OtherScalar, DIM > &other) const noexcept
Get the transformation left multiplied by the other transformation.
Definition TransformationT.hpp:893

Sequential TransformShape Method

//Make box
AMCAX::MakeBox mkbox = AMCAX::MakeBox(AMCAX::Point3(0., 0., 0.), AMCAX::Point3(1., 2., 3.));
AMCAX::TopoShape shape = mkbox.Shape();
//SetRotation
shape = AMCAX::TransformShape(shape, trsf);
shape = AMCAX::TransformShape(shape, trsf);
//Get a shape with a transformation
shape = AMCAX::TransformShape(shape, trsf);
//Write
AMCAX::STEP::STEPTool::Write(shape, "./test_box2.step");