ichiro-its / keisan Goto Github PK
View Code? Open in Web Editor NEWMath equations and algorithms package for ROS 2 project
Home Page: https://ichiro-its.github.io/keisan
License: MIT License
Math equations and algorithms package for ROS 2 project
Home Page: https://ichiro-its.github.io/keisan
License: MIT License
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 the Angle
object, so instead of just storing a double
, it could store other floating point data likes float
, long double
, etc.
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 Point2
and Point3
. So instead of just storing double
data, they could store other arithmetic data too likes int
, long
, float
, etc.
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 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
.
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 GitHub workflows to build and test this project using ROS 2 CI.
Add Point2
struct that represent a 2d point and Point3
struct that represent a 3d point. Both Point
s should support the following features:
x
, y
, (and z
) attributes in 64-bit float.Point
s and numeric value.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 unit test for Point2
and Point3
.
Add type template in Quaternion
and EulerAngles
. So instead of just storing double
data, they could store other floating point data too likes float
, long double
, etc.
Add a transformation class for Point3
.
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 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 a degree or a radian data by separating using an enum as a template argument instead of storing the boolean check.
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).
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.
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 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 support for angle equations as follow:
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 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
).
When calculating the direction of Point2(-5.0, 0.0)
instead of returning PI
, it returns 0.0
.
Add support for static double dot_product(Point, Point)
and double cross_product(Point, Point)
functions in the Point2
and Point3
structs.
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 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 a Matrix<size>
and a Vector<size>
template class that could be operated on each other (e.g. Matrix * Vector
, Matrix + Matrix
, etc.)
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 some distance equations in the Point2
and Point3
structs as follows:
distance_between(Point, Point)
function that calculate distance between two points.magnitude()
function that calculate distance of this point from the center coordinate (0, 0).normalize()
function that return a new normalized point which magnitude is 1.0
.A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.