Display_Lib_RPI 2.4.0
A C++ Library to connect electronic displays to Linux single board computers.
Loading...
Searching...
No Matches
Functions
rdlib_maths Namespace Reference

Name space for maths related utilities. More...

Functions

int mapValue (int x, int in_min, int in_max, int out_min, int out_max)
 Maps a value from one range to another using linear interpolation. This function takes an input value within a specified range and maps it to a corresponding value in a different output range using std::lerp.
 
float sineFromDegrees (float angle)
 Computes the sine of an angle given in degrees. This function converts the input angle from degrees to radians and then calculates the sine of that angle using the standard C++ sin function.
 
float cosineFromDegrees (float angle)
 Computes the cosine of an angle given in degrees. This function converts the input angle from degrees to radians and then calculates the cosine of that angle using the standard C++ cos function.
 
uint16_t generateColor (uint8_t value)
 This function is designed to return a color in the 16-bit RGB format based on the input value, creating a smooth transition between colors in different stages.
 

Detailed Description

Name space for maths related utilities.

Function Documentation

◆ cosineFromDegrees()

float rdlib_maths::cosineFromDegrees ( float  angle)

Computes the cosine of an angle given in degrees. This function converts the input angle from degrees to radians and then calculates the cosine of that angle using the standard C++ cos function.

Parameters
angleThe angle in degrees.
Returns
The cosine value of the given angle.

◆ generateColor()

uint16_t rdlib_maths::generateColor ( uint8_t  value)

This function is designed to return a color in the 16-bit RGB format based on the input value, creating a smooth transition between colors in different stages.

Parameters
valueinput value 1-127
Returns
16 bit color

The gradient is calculated by cycling through different color transitions as val increases, allowing for smooth visual effects such as changing hues or creating rainbow-like effects on an LCD. 1-127 will This will create a gradient color between blue and red based on the value.

◆ mapValue()

int rdlib_maths::mapValue ( int  x,
int  in_min,
int  in_max,
int  out_min,
int  out_max 
)

Maps a value from one range to another using linear interpolation. This function takes an input value within a specified range and maps it to a corresponding value in a different output range using std::lerp.

Parameters
xThe input value to map.
in_minThe lower bound of the input range.
in_maxThe upper bound of the input range.
out_minThe lower bound of the output range.
out_maxThe upper bound of the output range.
Returns
The mapped value in the output range.

◆ sineFromDegrees()

float rdlib_maths::sineFromDegrees ( float  angle)

Computes the sine of an angle given in degrees. This function converts the input angle from degrees to radians and then calculates the sine of that angle using the standard C++ sin function.

Parameters
angleThe angle in degrees.
Returns
The sine value of the given angle.