libft
Loading...
Searching...
No Matches
Data Structures | Macros | Typedefs | Functions
ft_math.h File Reference

Math and geometry utilities for libft. More...

+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  s_dpoint
 
struct  s_point
 

Macros

#define M_PI   3.14159265358979323846
 

Typedefs

typedef struct s_dpoint t_dpoint
 A simple struct for storing double float coordinates.
 
typedef struct s_point t_point
 A simple struct for storing integer coordinates.
 

Functions

double clamp (double value, double min, double max)
 Clamps a value between a minimum and maximum.
 
double deg_to_rad (double degrees)
 Converts an angle from degrees to radians.
 
t_dpoint divide_vector_by_scalar (t_dpoint vec, double scalar)
 Divides a 2D vector by a scalar.
 
double ft_euclidean_dist_dpoint (t_dpoint a, t_dpoint b)
 Computes Euclidean distance between two floating-point points.
 
int ft_euclidean_dist_point (t_point a, t_point b)
 Computes Euclidean distance between two integer points.
 
double ft_manhattan_dist_dpoint (t_dpoint a, t_dpoint b)
 Computes Manhattan distance between two floating-point points.
 
int ft_manhattan_dist_point (t_point a, t_point b)
 Computes Manhattan distance between two integer points.
 
t_dpoint get_direction_vector (t_dpoint from, t_dpoint to)
 Computes the vector pointing from one point to another.
 
double get_dot_product (t_dpoint vec1, t_dpoint vec2)
 Computes the dot product of two 2D vectors.
 
double get_fractional_part (double value)
 Gets the fractional part of a floating-point number.
 
t_dpoint get_normalized_vector (t_dpoint vector)
 Returns the normalized (unit length) vector.
 
t_dpoint get_unit_direction_vector (t_dpoint from, t_dpoint to)
 Computes the normalized direction vector between two points.
 
double get_vector_angle (t_dpoint vector)
 Computes the angle of a 2D vector in radians.
 
double get_vector_angle_between (t_dpoint from, t_dpoint to)
 Computes the angle between two points as a direction vector.
 
double get_vector_length (t_dpoint vec)
 Computes the length (magnitude) of a 2D vector.
 
double rad_to_deg (double radians)
 Converts an angle from radians to degrees.
 
double wrap_angle (double angle)
 Wraps an angle in radians to the range [0, 2π).
 
double wrap_in_range (double value, double range)
 Wraps a value within the range [0, range).
 

Detailed Description

Math and geometry utilities for libft.

Author
Toonsa
Date
2025/04/05

This header provides various math-related helpers including:

Note
Useful for graphics programming, simulations, and any system using basic geometry.