libft
Loading...
Searching...
No Matches
ft_math.h
Go to the documentation of this file.
1
19#ifndef FT_MATH_H
20#define FT_MATH_H
21
43/* ************************************************************************** */
44/* MACRO */
45/* ************************************************************************** */
46
47#ifndef M_PI
48#define M_PI 3.14159265358979323846
49#endif
50
51/* ************************************************************************** */
52/* TYPEDEFS */
53/* ************************************************************************** */
54
64typedef struct s_point
65{
66 int x;
67 int y;
69
79typedef struct s_dpoint
80{
81 double x;
82 double y;
84
85/* ************************************************************************** */
86/* FUNCTION PROTOTYPES */
87/* ************************************************************************** */
88
89double deg_to_rad(double degrees);
90double rad_to_deg(double radians);
91double wrap_angle(double angle);
96double clamp(double value, double min, double max);
97double get_fractional_part(double value);
98double wrap_in_range(double value, double range);
99double get_vector_length(t_dpoint vec);
100t_dpoint divide_vector_by_scalar(t_dpoint vec, double scalar);
102double get_vector_angle(t_dpoint vector);
106double get_dot_product(t_dpoint vec1, t_dpoint vec2);
109#endif // FT_MATH_H
double x
Definition ft_math.h:81
double y
Definition ft_math.h:82
int x
Definition ft_math.h:66
int y
Definition ft_math.h:67
double get_vector_angle_between(t_dpoint from, t_dpoint to)
Computes the angle between two points as a direction vector.
Definition vector_utils.c:174
double get_vector_angle(t_dpoint vector)
Computes the angle of a 2D vector in radians.
Definition vector_utils.c:151
t_dpoint get_direction_vector(t_dpoint from, t_dpoint to)
Computes the vector pointing from one point to another.
Definition vector_utils.c:130
double get_vector_length(t_dpoint vec)
Computes the length (magnitude) of a 2D vector.
Definition vector_utils.c:33
t_dpoint get_normalized_vector(t_dpoint vector)
Returns the normalized (unit length) vector.
Definition vector_utils.c:79
double wrap_angle(double angle)
Wraps an angle in radians to the range [0, 2π).
Definition angle_utils.c:74
struct s_point t_point
A simple struct for storing integer coordinates.
double clamp(double value, double min, double max)
Clamps a value between a minimum and maximum.
Definition math_utils.c:33
double ft_manhattan_dist_dpoint(t_dpoint a, t_dpoint b)
Computes Manhattan distance between two floating-point points.
Definition distance_utils.c:53
struct s_dpoint t_dpoint
A simple struct for storing double float coordinates.
int ft_manhattan_dist_point(t_point a, t_point b)
Computes Manhattan distance between two integer points.
Definition distance_utils.c:34
double rad_to_deg(double radians)
Converts an angle from radians to degrees.
Definition angle_utils.c:31
double deg_to_rad(double degrees)
Converts an angle from degrees to radians.
Definition angle_utils.c:52
double get_dot_product(t_dpoint vec1, t_dpoint vec2)
Computes the dot product of two 2D vectors.
Definition vector_utils.c:105
double get_fractional_part(double value)
Gets the fractional part of a floating-point number.
Definition math_utils.c:55
int ft_euclidean_dist_point(t_point a, t_point b)
Computes Euclidean distance between two integer points.
Definition distance_utils.c:73
double wrap_in_range(double value, double range)
Wraps a value within the range [0, range).
Definition math_utils.c:81
double ft_euclidean_dist_dpoint(t_dpoint a, t_dpoint b)
Computes Euclidean distance between two floating-point points.
Definition distance_utils.c:93
t_dpoint divide_vector_by_scalar(t_dpoint vec, double scalar)
Divides a 2D vector by a scalar.
Definition vector_utils.c:56
t_dpoint get_unit_direction_vector(t_dpoint from, t_dpoint to)
Computes the normalized direction vector between two points.
Definition vector_utils.c:199
Definition ft_math.h:80
Definition ft_math.h:65