/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   vec_math.h                                         :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: qmennen <qmennen@student.codam.nl>         +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2025/04/25 10:11:44 by whaffman          #+#    #+#             */
/*   Updated: 2025/05/06 15:20:37 by qmennen          ###   ########.fr       */
/*                                                                            */
/* ************************************************************************** */

#ifndef VEC_MATH_H
#define VEC_MATH_H
#include "types.h"

/**
 * @brief Calculates the distance between two 2D vectors.
 *
 * @param a The first 2D vector.
 * @param b The second 2D vector.
 * @return The distance between vector a and vector b as a double.
 */
double dist(t_vec2 a, t_vec2 b);

/**
 * @brief Calculates the norm (length) of a 2D vector.
 *
 * @param a The 2D vector.
 * @return The norm of vector a as a double.
 */
double norm(t_vec2 a);

/**
 * @brief Calculates the dot product of two 2D vectors.
 *
 * @param a The first 2D vector.
 * @param b The second 2D vector.
 * @return The dot product of vector a and vector b as a double.
 */
double dot(t_vec2 a, t_vec2 b);

/**
 * @brief Calculates the distance from a point to a line.
 *
 * @param point The point to calculate the distance from.
 * @param line The line defined by a (support)point and a direction.
 * @return The distance from the point to the line as a double.
 */
double dist_point_line(t_vec2 point, t_vec2_line line);

/**
 * @brief Adds two 2D vectors.
 *
 * @param a The first 2D vector.
 * @param b The second 2D vector.
 * @return The sum of vector a and vector b as a new 2D vector.
 */
t_vec2 add(t_vec2 a, t_vec2 b);

/**
 * @brief Subtracts one 2D vector from another.
 *
 * @param a The first 2D vector.
 * @param b The second 2D vector to subtract from the first.
 * @return The result of subtracting vector b from vector a as a new 2D vector.
 */
t_vec2 sub(t_vec2 a, t_vec2 b);

/**
 * @brief Multiplies a 2D vector by a scalar.
 *
 * @param a The 2D vector to multiply.
 * @param b The scalar to multiply the vector by.
 * @return The result of multiplying vector a by scalar b as a new 2D vector.
 */
t_vec2 mul(t_vec2 a, double b);

/**
 * @brief Rotates a 2D vector by a given angle.
 *
 * @param a The 2D vector to rotate.
 * @param angle The angle in radians to rotate the vector by.
 * @return The rotated vector as a new 2D vector.
 */
t_vec2 rot(t_vec2 a, double angle);

/**
 * @brief Calculates the perpendicular vector of a 2D vector.
 *
 * @param a The 2D vector to calculate the perpendicular of.
 * @return The perpendicular vector as a new 2D vector.
 */
t_vec2 perp(t_vec2 a);

#endif // VEC_MATH_H