naev 0.12.5
nmath.c File Reference

Some math routines for naev. More...

#include "nmath.h"
#include "array.h"
#include "log.h"
#include "rng.h"
Include dependency graph for nmath.c:

Go to the source code of this file.

Functions

int nmath_solve2Eq (double results[2], double a, double b, double c)
 Solves the equation: a * x^2 + b * x + c = 0.
double max3 (double v1, double v2, double v3)
 Returns the maximum of 3 values.
double min3 (double v1, double v2, double v3)
 Returns the minimum of 3 values.
void arrayShuffle (void **array)
 Randomly sorts an array (array.h) of pointers in place with the Fisher-Yates shuffle.
int rectOverlap (double x, double y, double w, double h, double x2, double y2, double w2, double h2)
 Checks whether two rectangles overlap at any point.
double ease_SineInOut (double x)
 Simple symmetric sine-based easing.
double ease_QuadraticInOut (double x)
 Simple symmetric quadratic easing.
double ease_CubicInOut (double x)
 Simple symmetric cubic easing.

Detailed Description

Some math routines for naev.

Definition in file nmath.c.

Function Documentation

◆ arrayShuffle()

void arrayShuffle ( void ** array)

Randomly sorts an array (array.h) of pointers in place with the Fisher-Yates shuffle.

Definition at line 68 of file nmath.c.

◆ ease_CubicInOut()

double ease_CubicInOut ( double x)

Simple symmetric cubic easing.

Definition at line 122 of file nmath.c.

◆ ease_QuadraticInOut()

double ease_QuadraticInOut ( double x)

Simple symmetric quadratic easing.

Definition at line 112 of file nmath.c.

◆ ease_SineInOut()

double ease_SineInOut ( double x)

Simple symmetric sine-based easing.

Definition at line 104 of file nmath.c.

◆ max3()

double max3 ( double v1,
double v2,
double v3 )

Returns the maximum of 3 values.

Definition at line 46 of file nmath.c.

◆ min3()

double min3 ( double v1,
double v2,
double v3 )

Returns the minimum of 3 values.

Definition at line 56 of file nmath.c.

◆ nmath_solve2Eq()

int nmath_solve2Eq ( double results[2],
double a,
double b,
double c )

Solves the equation: a * x^2 + b * x + c = 0.

Parameters
resultsStores both results.
aQuadratic parameter.
bLinear parameter.
cOffset coefficient.
Returns
0 on success, -1 on error (or complex).

Definition at line 30 of file nmath.c.

◆ rectOverlap()

int rectOverlap ( double x,
double y,
double w,
double h,
double x2,
double y2,
double w2,
double h2 )

Checks whether two rectangles overlap at any point.

Parameters
xX coordinate of first rectangle
yY coordinate of first rectangle
wWidth of first rectangle
hHeight of first rectangle
x2X coordinate of second rectangle
y2Y coordinate of second rectangle
w2Width of second rectangle
h2Height of second rectangle
Returns
1 if the rectangles overlap, 0 otherwise.

Definition at line 91 of file nmath.c.