Giter Site home page Giter Site logo

ichiro-its / keisan Goto Github PK

View Code? Open in Web Editor NEW
1.0 3.0 1.0 833 KB

Math equations and algorithms package for ROS 2 project

Home Page: https://ichiro-its.github.io/keisan

License: MIT License

CMake 1.43% C++ 98.57%
math math-equations algorithms ros ros2 keisan

keisan's People

Contributors

finesaaa avatar jayantita avatar maroqijalil avatar nathan24zz avatar segara2410 avatar threeal avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Forkers

threeal

keisan's Issues

Add Transform Class

Add support for a Transform's class that could enable transformation of Point2 and Point3 using translation, rotation, and scale transform. It should works as follow:

Point2 point;
Transform2 transform;

transform.set_translation(some_translation);
transform.set_euler(some_euler);
...

Point2 transformed_point = transform * point;

Use Template in Angle

Use template in the Angle object, so instead of just storing a double, it could store other floating point data likes float, long double, etc.

Change to pure C++ Library

Change from ROS 2 package into a pure C++ library (still using CMake, but without ament_cmake).

This change is needed because ROS 2 build dependency make it hard to implement a newer C++ version (C++17), custom format/lint rules, binary deployment, etc.

Add Type Template in Points

Add type template in Point2 and Point3. So instead of just storing double data, they could store other arithmetic data too likes int, long, float, etc.

Add Support to Clamp Number

Add a double clamp_number(double value, double min, double max) function that will return a clamped value of input value between min and max values.

Add Sign Function

Add a number_sign(double val) function which will be used to find sign of a specified number. It must return 1.0 when the number is positive or zero, else it must return -1.0.

Eliminate Debian Deployment Workflows

This issue proposes the removal of the deploy-debian-nightly.yml and deploy-debian-stable.yml workflows since Debian deployment is no longer in use for this project.

Add Points Struct

Add Point2 struct that represent a 2d point and Point3 struct that represent a 3d point. Both Points should support the following features:

  • Have public x, y, (and z) attributes in 64-bit float.
  • Addition (+) and substraction (-) operation against other Points and numeric value.
  • Multiplication (*) and division (/) operation against numeric value.

Use Matrix for Transformation

As in #26 addition, it's better to use matrix for transformation rather than manually calculate each translation, rotation, and scale transformation to be used.

Add Support to Scale Number

Add support to scale_number() function which works like map_number() function but without minimum and maximum range, just source number and target number. It's also the better choice to be used on the rad_to_deg() and deg_to_rad() functions

Add Type Template in Matrices

Add type template in Matrix, SquareMatrix, and Vector. So instead of just storing double data, they could store other arithmetic data too likes int, long, float, etc.

Modify How Angle Store Data

Modify how angle store a degree or a radian data by separating using an enum as a template argument instead of storing the boolean check.

Add Trigonometry Equation for Rad and Deg

Add several trigonometry functions (e.g. sin, cos, tan, asin, ...) in the form of radian and degree (e.g. sin_rad and sin_deg for sin equation that specify angle type to be used).

Add Python Support

Rename the current keisan package into keisan_cpp (as a c++ implementation of Keisan project) and move it to the sub directory of this project. And add a new package named keisan_py that will be used as a Python implementation of Keisan project.

Separate Transformation

To make the transformation process simpler, especially when we need to do rotation transform only. Instead of doing this:

Transform2 transform();
transform.set_rotation(90.0);

auto transformed_point = transform * point;

It's better to write that like this:

auto transformed_point = Rotation2(90.0) * point;

In case we need to do all the transformation, it could also be more simpler:

auto transformed_point = Translation2(-5.0, 0.0) * Rotation2(90.0) * point;

And the good news is that we could specify the order of transformation. That's why i suggest it's better to separate the transformation into each of it's components (e.g. Transform2 will be separated into Rotation2, Scale2 and Translation2).

Use Template For Most Equation

Use template function for number and angle equations so it would also work for any kind of number types from int, long, float, etc. not just for double type.

Add Angle Equations

Add support for angle equations as follow:

  • PI constant.
  • Wrap angle value between -PI to PI (Any angle equation should return a value between those values).
  • Conversion between angles in radian and degree.

Modify Distance and Direction Equations

Currently the distance and the direction equations in the Point classess are as follows:

static double distance_between(const Point & point_a, const Point & point_b);
static double angle_between(const Point & point_a, const Point & point_b);

double magnitude() const;
double direction() const;

To make the usage simpler, instead of calling:

auto distance = keisan::Point2::distance_between(a, b);

It's better to move the distance_between and angle_between function to the namespace scope, not in the class scope as a static function. So the function could be simply just be called like this:

auto distance = keisan::distance_between(a, b);

Because how c++ works, it's possible to have multiple function name with different argument type and result type. Hence it's fine to put it on global scope.

Also, sometimes it's also more convenient to just call a distance and a direction equation like this:

auto distance = a.distance_to(b);

That's why it's better to also add function to calculate distance and direction equation between self and other Point. So aside from previously mentioned functions, also add the following function to the Point classes:

double distance_to(const Point & point);
double direction_to(const Point & point);

Add Delta Angle Equation

Add a delta_deg(double) and a delta_rad(double) functions that calculate the minimum delta between two angles (100.0 and -100.0 should be 160.0 instead of 200.0).

Add Direction Equation

Add a double direction() function that calculate angle/direction of a point (treated as a vector) and a static double angle_between(Point, Point) function that calculate angle between two points in radian.

Cover All Types in Angle Test

Cover every type (float, double, int, etc.) during Angle test. Some solution is by using combination of function macros as follows:

#define FUNCTION(TYPE) \
{ \
  /* some code */ \
}

#define ITERATE_ALL_TYPES(FUNCTION) \
{ \
  FUNCTION(float) \
  FUNCTION(double) \
  FUNCTION(int) \
  /* etc. */ \
}

Or by passing generic functions, or lambdas.

Add Matrix and Vector

Add a Matrix<size> and a Vector<size> template class that could be operated on each other (e.g. Matrix * Vector, Matrix + Matrix, etc.)

Modify How Trigonometry Functions Get Called

I suggest to declare trigonometry functions as method of Angle instead of declare it as an independent function. In the end the trigonometry function could be called as follows:

const auto angle = 0.5_deg;
const auto cos_of_angle = angle.cos();

const auto sin_value = (2_pi_rad).sin();

const auto new_angle = Angle::atan(1);

Add Distance Equation in Point Structs

Add some distance equations in the Point2 and Point3 structs as follows:

  • A static distance_between(Point, Point) function that calculate distance between two points.
  • A magnitude() function that calculate distance of this point from the center coordinate (0, 0).
  • A normalize() function that return a new normalized point which magnitude is 1.0.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.