Skip to content

Commit

Permalink
Merge pull request #976 from DLR-SC/975-guidecurve-coordinate-system
Browse files Browse the repository at this point in the history
Fix #975: Transform rX-Direction of guide curve with wing coordinate system
  • Loading branch information
joergbrech authored Nov 21, 2023
2 parents 5f3e172 + f8f027e commit 45a9428
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/wing/CTiglWingSegmentGuidecurveBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ std::vector<gp_Pnt> CTiglWingSegmentGuidecurveBuilder::BuildGuideCurvePnts(const
}

// get local x-direction for the guide curve
gp_Dir rxDir = gp_Dir(1., 0., 0.);
gp_Dir rxDir = wingTransform.Transform(gp_Dir(1., 0., 0.));
if (guideCurve->GetRXDirection()) {
rxDir.SetX(guideCurve->GetRXDirection()->GetX());
rxDir.SetY(guideCurve->GetRXDirection()->GetY());
Expand Down
42 changes: 42 additions & 0 deletions tests/unittests/tiglWingGuideCurves.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
#include "CCPACSGuideCurveAlgo.h"
#include "CCPACSWingSegment.h"
#include "tiglcommonfunctions.h"
#include "CTiglWingSegmentGuidecurveBuilder.h"

/******************************************************************************/

Expand Down Expand Up @@ -457,3 +458,44 @@ TEST_F(WingGuideCurve, tiglWingGuideCurve_CCPACSWingSegment)
ASSERT_NEAR(predictedPoint.Z(), point.Z(), 1E-14);
}
}

TEST_F(WingGuideCurve, bug975)
{
//https://github.com/DLR-SC/tigl/issues/975

tigl::CCPACSConfigurationManager& manager = tigl::CCPACSConfigurationManager::GetInstance();
tigl::CCPACSConfiguration& config = manager.GetConfiguration(tiglHandle);
tigl::CCPACSWing& wing = config.GetWing(1);


tigl::CCPACSWingSegment& segment1 = wing.GetSegment(1);
tigl::CTiglWingSegmentGuidecurveBuilder builder(segment1);

auto const& guideCurves = segment1.GetGuideCurves();
if(guideCurves) {
tigl::CCPACSGuideCurve const& guidecurve = guideCurves->GetGuideCurve(1);
auto points_before = builder.BuildGuideCurvePnts(&guidecurve);

tigl::CCPACSTransformation& trafo = wing.GetTransformation();
trafo.setRotation(tigl::CTiglPoint(0, 90, 0));
wing.SetTransformation(trafo);
tigl::CTiglTransformation const& wingTrafo = wing.GetTransformationMatrix();

auto points_after = builder.BuildGuideCurvePnts(&guidecurve);
int idx = 0;
for (auto const& p : points_after) {

// per design, the guide curve should have a zero x-component
EXPECT_NEAR(p.X(), 0.0, 1e-12);

// transforming the guide curve points of the untransformed wing should
// yield the same points as building the points after transforming the wing
gp_Pnt pt = wingTrafo.Transform(points_before[idx++]);
EXPECT_NEAR(p.X(), pt.X(), 1e-12);
EXPECT_NEAR(p.Y(), pt.Y(), 1e-12);
EXPECT_NEAR(p.Z(), pt.Z(), 1e-12);

}
}

}

0 comments on commit 45a9428

Please sign in to comment.