Commit 57c6481e authored by Jesse Mapel's avatar Jesse Mapel
Browse files

Added Orientations operations (#360)

* Ticked version #

* Added Orientations::inverse

* Added Orientation inverse test

* Added Orientation multiplication operaotrs

* Added Vector operators

* Now using new operator

* Improved docs

* Small fix for exported target
parent 8bda7736
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -7,7 +7,7 @@
# Specify the required version of CMake.
# cmake 3.10 required for ctest/gtest integration
cmake_minimum_required(VERSION 3.10)
project(ale VERSION 0.8.0 DESCRIPTION "Abstraction Library for Ephemerides ")
project(ale VERSION 0.8.1 DESCRIPTION "Abstraction Library for Ephemerides ")

# include what we need
include(GNUInstallDirs)
@@ -53,7 +53,8 @@ set(ALE_SRC_FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/InterpUtils.cpp
                  ${CMAKE_CURRENT_SOURCE_DIR}/src/Orientations.cpp
                  ${CMAKE_CURRENT_SOURCE_DIR}/src/States.cpp
                  ${CMAKE_CURRENT_SOURCE_DIR}/src/Isd.cpp
                  ${CMAKE_CURRENT_SOURCE_DIR}/src/Util.cpp)
                  ${CMAKE_CURRENT_SOURCE_DIR}/src/Util.cpp
                  ${CMAKE_CURRENT_SOURCE_DIR}/src/Vectors.cpp)
set(ALE_HEADER_FILES ${ALE_BUILD_INCLUDE_DIR}/InterpUtils.h
                     ${ALE_BUILD_INCLUDE_DIR}/Rotation.h
                     ${ALE_BUILD_INCLUDE_DIR}/Orientations.h
+1 −0
Original line number Diff line number Diff line
@@ -3,5 +3,6 @@ set(${CMAKE_FIND_PACKAGE_NAME}_CONFIG ${CMAKE_CURRENT_LIST_FILE})
find_package_handle_standard_args(@PROJECT_NAME@ CONFIG_MODE)

if(NOT TARGET @PROJECT_NAME@::ale)
    find_package(nlohmann_json REQUIRED)
    include("${CMAKE_CURRENT_LIST_DIR}/aleTargets.cmake")
endif()
+24 −0
Original line number Diff line number Diff line
@@ -71,15 +71,35 @@ namespace ale {
      bool invert=false
    ) const;

    /**
     * Add an additional constant multiplication.
     * This is equivalent to left multiplication by a constant rotation
     */
    Orientations &addConstantRotation(const Rotation &addedConst);

    /**
     * Multiply this orientation by another orientation
     */
    Orientations &operator*=(const Orientations &rhs);

    /**
     * Multiply this orientation by a constant rotation
     */
    Orientations &operator*=(const Rotation &rhs);

    /**
     * Invert the orientations.
     * Note that inverting a set of orientations twice does not result in
     * the original orientations. the constant rotation is applied after the
     * time dependent rotation. This means in the inverse, the constant
     * rotation is applied first and then the time dependent rotation.
     * So, the inverted set of orientations is entirely time dependent.
     * Then, the original constant rotations cannot be recovered when inverting
     * again. The set of orientations will still operate the same way, but its
     * internal state will not be the same.
     */
     Orientations inverse() const;

  private:
    std::vector<Rotation> m_rotations;
    std::vector<ale::Vec3d> m_avs;
@@ -88,6 +108,10 @@ namespace ale {
    std::vector<int> m_constFrames;
    Rotation m_constRotation;
  };

  Orientations operator*(Orientations lhs, const Rotation &rhs);
  Orientations operator*(const Rotation &lhs, Orientations rhs);
  Orientations operator*(Orientations lhs, const Orientations &rhs);
}

#endif
+29 −0
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@
#define ALE_VECTORS_H

#include <stdexcept>
#include <vector>

namespace ale {
  /** A 3D cartesian vector */
@@ -22,7 +23,35 @@ namespace ale {

    Vec3d(double x, double y, double z) : x(x), y(y), z(z) {};
    Vec3d() : x(0.0), y(0.0), z(0.0) {};
    Vec3d &operator*=(double scalar) {
      x *= scalar;
      y *= scalar;
      z *= scalar;
      return *this;
    };

    Vec3d &operator+=(Vec3d addend) {
      x += addend.x;
      y += addend.y;
      z += addend.z;
      return *this;
    };

    Vec3d &operator-=(Vec3d addend) {
      x -= addend.x;
      y -= addend.y;
      z -= addend.z;
      return *this;
    };
  };

  Vec3d operator*(double scalar, Vec3d vec);

  Vec3d operator*(Vec3d vec, double scalar);

  Vec3d operator+(Vec3d leftVec, const Vec3d &rightVec);

  Vec3d operator-(Vec3d leftVec, const Vec3d &rightVec);
}

#endif
+1 −1
Original line number Diff line number Diff line
@@ -4,7 +4,7 @@ import sys
from setuptools import setup, find_packages

NAME = "Ale"
VERSION = "0.8.0"
VERSION = "0.8.1"

# To install the library, run the following
#
Loading