Discussion: Rethink TiGL's implementation around coordinate systems and transformations #911
Replies: 2 comments
-
I can still pretty much recall most of the details from our discussions. We had two classes
This basically defines a tree of coordinate systems, starting at the root coordinate system. This enables us to create a function like template <typename T>
T transformCoordinates(CoordinateSystem fromSystem, CoordinateSytem toSystem, T toTransform); This allows to transform between all kinds of coordinate systems. In addition, a cpacs node like A This would be some pseudo code of the RelativelyPositionedComponent class: struct CoordinateSystem
{
CoordinateSystem();
CoordinateSystem(Transformation);
CoordinateSystem(CoordinateSystem parent, Transformation);
};
struct RelativelyPositionedComponent
{
RelativelyPositionedComponent(RelativelyPositionedComponent parentComponent)
: localTranslation(parentComponent.localTranslation, myCpacsTransformation.translation)
: local(localTranslation, myCpacsTransformation.rotation)
{}
CoordinateSystem localTranslation;
CoordinateSystem local;
}; Hence, the coordinate system |
Beta Was this translation helpful? Give feedback.
-
I will think about it and get back to you! |
Beta Was this translation helpful? Give feedback.
-
Currently, TiGL uses the
CTiglRelativelyPositionedComponent
to manage CPACS transformations relative to each other.There are a few problems with the current implementation, which makes working with transformations error-prone and cumbersome.
CTiglRelativelyPositionedComponent
, for example sections or elements. There is no single API to handle transformations and coordinate transform and every class handles it slightly differently or not at all. There are a few places in the TiGL source code, where chained transformations are performed "manually".CCPACSTransformation
keeps a pointer to a parent CPACS node, which could be a physical component of an airplane. Conceptually, a transformation is a linear map from R4 to R4 and should be agnostic of what an airplane is. As a consequence, every time a new CPACS node is added that has a transformation, theCCPACSTransformation
node must be adapted. I would argue that it is okay to keep the class as it is and live with this, as it is how the CPACS Code Generator works. But it probably makes sense to use a different transformation class for relative coordinate systems, that is convertible to and from aCCPACSTransformation
.Proposal:
CTiglTransformation
. This class stores a private 4x4 matrix as the raw transformation and a pointer/optional to a parent transformation. With this, it should be possible to build a tree of coordinate systems. We should somehow guard against circular references.Transform
class provides methods along the lines ofVector from(Vector const& x, Transform const& origin_transform)
to transform a vector defined in the coordinate systemorigin_transform
to local coordinates andVector to(Vector const& y, Transform target_transform)
to transform a vector defined in local coordinates to the coordinate systemtarget_transform
.This would be a big refactor in TiGL, but I think the effort is worth it.
@rainman110, tagging you here because I remember we had a discussion about this quite a while back and never found the time to follow up on it. @AntonReiswich, any thoughts?
Beta Was this translation helpful? Give feedback.
All reactions