Skip to content

Commit

Permalink
WIP: add transformation and tranformation
Browse files Browse the repository at this point in the history
  • Loading branch information
sethrj committed Aug 8, 2023
1 parent ab599b4 commit 0bd7ba9
Show file tree
Hide file tree
Showing 9 changed files with 365 additions and 134 deletions.
3 changes: 3 additions & 0 deletions src/orange/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ list(APPEND SOURCES
detail/RectArrayInserter.cc
detail/UnitInserter.cc
surf/SurfaceIO.cc
transform/TransformTransformer.cc
transform/TransformTranslator.cc
transform/Transformation.cc
)

if(CELERITAS_USE_JSON)
Expand Down
134 changes: 0 additions & 134 deletions src/orange/Translator.hh

This file was deleted.

32 changes: 32 additions & 0 deletions src/orange/transform/TransformTransformer.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//----------------------------------*-C++-*----------------------------------//
// Copyright 2023 UT-Battelle, LLC, and other Celeritas developers.
// See the top-level COPYRIGHT file for details.
// SPDX-License-Identifier: (Apache-2.0 OR MIT)
//---------------------------------------------------------------------------//
//! \file orange/transform/TransformTransformer.cc
//---------------------------------------------------------------------------//
#include "TransformTransformer.hh"

#include "corecel/math/MatrixUtils.hh"

namespace celeritas
{
//---------------------------------------------------------------------------//
/*!
* Apply a translation to a transform.
*/
Transformation TransformTransformer::operator()(Transformation const& tr) const
{
}

//---------------------------------------------------------------------------//
/*!
* Apply a transformation to a translation.
*/
Translation TransformTransformer::operator()(Translation const& tl) const
{
return Translation{tl.translation() + tr_};
}

//---------------------------------------------------------------------------//
} // namespace celeritas
39 changes: 39 additions & 0 deletions src/orange/transform/TransformTransformer.hh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//----------------------------------*-C++-*----------------------------------//
// Copyright 2023 UT-Battelle, LLC, and other Celeritas developers.
// See the top-level COPYRIGHT file for details.
// SPDX-License-Identifier: (Apache-2.0 OR MIT)
//---------------------------------------------------------------------------//
//! \file orange/transform/TransformTransformer.hh
//---------------------------------------------------------------------------//
#pragma once

#include "Transformation.hh"

namespace celeritas
{
//---------------------------------------------------------------------------//
/*!
* Apply a transformation to another transformation.
*
* This accepts a daughter-to-parent transformation: the transformation needed
* to relocate a "lower" universe to a new coordinate system in the "higher"
* universe.
*/
class TransformTransformer
{
public:
//! Construct with the new reference frame of the transformation
explicit TransformTransformer(Transformation const& tr) : tr_{tr} {}

//!@{
//! Transform a transformation
Transformation operator()(Transformation const&) const;
Transformation operator()(Translation const&) const;
//!@}

private:
Transformation tr_;
};

//---------------------------------------------------------------------------//
} // namespace celeritas
33 changes: 33 additions & 0 deletions src/orange/transform/TransformTranslator.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//----------------------------------*-C++-*----------------------------------//
// Copyright 2023 UT-Battelle, LLC, and other Celeritas developers.
// See the top-level COPYRIGHT file for details.
// SPDX-License-Identifier: (Apache-2.0 OR MIT)
//---------------------------------------------------------------------------//
//! \file orange/transform/TransformTranslator.cc
//---------------------------------------------------------------------------//
#include "TransformTranslator.hh"

#include "corecel/math/MatrixUtils.hh"

namespace celeritas
{
//---------------------------------------------------------------------------//
/*!
* Apply a translation to a transform.
*/
Transformation TransformTranslator::operator()(Transformation const& tr) const
{
return Transformation{tr.rotation(), tr.translation() + tr_};
}

//---------------------------------------------------------------------------//
/*!
* Apply a translation to another translation.
*/
Translation TransformTranslator::operator()(Translation const& tl) const
{
return Translation{tl.translation() + tr_};
}

//---------------------------------------------------------------------------//
} // namespace celeritas
37 changes: 37 additions & 0 deletions src/orange/transform/TransformTranslator.hh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//----------------------------------*-C++-*----------------------------------//
// Copyright 2023 UT-Battelle, LLC, and other Celeritas developers.
// See the top-level COPYRIGHT file for details.
// SPDX-License-Identifier: (Apache-2.0 OR MIT)
//---------------------------------------------------------------------------//
//! \file orange/transform/TransformTranslator.hh
//---------------------------------------------------------------------------//
#pragma once

namespace celeritas
{
//---------------------------------------------------------------------------//
/*!
* Apply a translation to a transform to get another transform.
*
* This accepts a daughter-to-parent translation: the translation needed to
* relocate a "lower" universe to a new coordinate system in the "higher"
* universe.
*/
class TransformTranslator
{
public:
//! Construct with the new reference frame of the translation
explicit TransformTransformer(Translation const& tr) : tr_{tr} {}

//// TRANSFORMATIONS ////

Transformation operator()(Transformation const&) const;

Translation operator()(Translation const&) const;

private:
Translation tr_;
};

//---------------------------------------------------------------------------//
} // namespace celeritas
31 changes: 31 additions & 0 deletions src/orange/transform/Transformation.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//----------------------------------*-C++-*----------------------------------//
// Copyright 2023 UT-Battelle, LLC, and other Celeritas developers.
// See the top-level COPYRIGHT file for details.
// SPDX-License-Identifier: (Apache-2.0 OR MIT)
//---------------------------------------------------------------------------//
//! \file orange/transform/Transformation.cc
//---------------------------------------------------------------------------//
#include "Transformation.hh"

namespace celeritas
{
//---------------------------------------------------------------------------//
/*!
* Construct and check the input.
*/
Transformation::Transformation(Mat3 const& rot, Real3 const& trans)
: rot_(rot), tra_(trans)
{
}

//---------------------------------------------------------------------------//
/*!
* Promote from a translation.
*/
Transformation::Transformation(Translation const& tr)
: rot_{{1, 0, 0}, {0, 1, 0}, {0, 0, 1}}, tra_{tr.translation()}
{
}

//---------------------------------------------------------------------------//
} // namespace celeritas
Loading

0 comments on commit 0bd7ba9

Please sign in to comment.