MPLABĀ® Harmony Graphics Suite
GFX v3.13.0
Legato API Documentation
|
Defines common math functions for general use. More...
#include "gfx/legato/common/legato_common.h"
Go to the source code of this file.
Data Structures | |
struct | leArcQuadrantQuery |
struct | leResolvedAngleRanges |
Typedefs | |
typedef struct leResolvedAngleRanges | leResolvedAngleRanges |
Enumerations | |
enum | LE_TRIG_FUNCTION_TYPE { LE_TRIG_SINE_TYPE, LE_TRIG_COSINE_TYPE } |
Used to define the types of trig functions. More... | |
enum | LE_QUADRANT { LE_Q1, LE_Q2, LE_Q3, LE_Q4 } |
Used to define the basic four quandrants of a coordinate plane. More... | |
enum | leArcDir { LE_CCW, LE_CW } |
Used to define arc direction. More... | |
Functions | |
int32_t | leMini (int32_t l, int32_t r) |
Calculate minimum of two integers. More... | |
int32_t | leMaxi (int32_t l, int32_t r) |
Calculate maximum of two integers. More... | |
float | leMinf (float l, float r) |
Calculate minimum of two floats. More... | |
float | leMaxf (float l, float r) |
Calculate maximum of two floats. More... | |
int32_t | leClampi (int32_t min, int32_t max, int32_t i) |
Calculates clamp of an integer. More... | |
float | leClampf (float min, float max, float f) |
Calculate clamp of a float. More... | |
uint32_t | lePercent (uint32_t l, uint32_t r) |
Calculate percent of number. More... | |
uint32_t | lePercentWholeRounded (uint32_t l, uint32_t r) |
Calculate percent whole rounded. More... | |
uint32_t | lePercentOf (uint32_t num, uint32_t percent) |
Calculate percent of a number. More... | |
void | lePercentOfDec (uint32_t num, uint32_t percent, uint32_t *whl, uint32_t *dec) |
Calculate percent of a decimal. More... | |
uint32_t | leScaleInteger (uint32_t num, uint32_t oldMax, uint32_t newMax) |
Calculate the scale of an integer. More... | |
int32_t | leScaleIntegerSigned (int32_t num, int32_t oldMax, int32_t newMax) |
Calculate the scale of signed integer. More... | |
uint32_t | leAbsoluteValue (int32_t val) |
Calculates the absolute value of a signed integer. More... | |
int32_t | leLerp (int32_t x, int32_t y, uint32_t per) |
Calculates a linear interpolation of an integer based on a percentage between two signed points. More... | |
int32_t | leDivideRounding (int32_t num, int32_t denom) |
Performs a linear interpolation of an integer based on a percentage between two signed points. More... | |
leResult | lePolarToXY (int32_t r, int32_t a, lePoint *p) |
Generate points in an arc. More... | |
int32_t | leNormalizeAngle (int32_t t) |
Normalize an angle between 0 - 360. More... | |
int32_t | leSin (int32_t v) |
Calculate sin of a number. More... | |
int32_t | leCos (int32_t v) |
Calculate cosine of a number. More... | |
leResult | leEllipsePoint (int32_t t, int32_t a, int32_t b, int32_t theta, lePoint *p) |
Calculates points in an arc. More... | |
double | leAtan (double val) |
Calculate atan of points. More... | |
leBool | lePointOnLineSide (lePoint *pt, lePoint *linePt, lePoint *sign) |
void | leSortPointsX (lePoint *p1, lePoint *p2) |
Sorts two points on the X axis. More... | |
void | leSortPointsY (lePoint *p1, lePoint *p2) |
Sorts two points on the Y axis. More... | |
int32_t | leGetXGivenYOnLine (lePoint p1, lePoint p2, int32_t y) |
Project point. More... | |
int32_t | leGetYGivenXOnLine (lePoint p1, lePoint p2, int32_t x) |
Project Y give X. More... | |
void | leRotatePoint (lePoint pos, lePoint org, int32_t ang, lePoint *res) |
Rotates point. More... | |
void | leRotatedRectBounds (leRect rect, int32_t ang, leRect *res) |
Calculate bounding rectangle. More... | |
float | leSqrt (const float x) |
void | lePointOnCircle (uint32_t radius, int32_t angle, lePoint *res) |
uint32_t | leDegreesFromPercent (uint32_t percent, int32_t centerAngle, int32_t startAngle) |
uint32_t | lePercentFromDegrees (uint32_t degrees, int32_t centerAngle, int32_t startAngle) |
void | leNormalizeAngles (int32_t startAngle, int32_t spanAngle, int32_t *normalizedStartAngle, int32_t *normalizedEndAngle) |
void | leResolveAngles (int32_t startAngle, int32_t spanAngle, leResolvedAngleRanges *res) |
float | leRound (float flt) |
Defines common math functions for general use.
This is an array implementation that is used internally by the Legato user interface library.
enum LE_QUADRANT |
Used to define the basic four quandrants of a coordinate plane.
Used to define the types of trig functions.
Trigonomtry is used in Legato.
enum leArcDir |
uint32_t leAbsoluteValue | ( | int32_t | val | ) |
Calculates the absolute value of a signed integer.
Calculates the absolute value of val.
param1 | val is an integer. |
double leAtan | ( | double | val | ) |
Calculate atan of points.
Calculate atan of x and y.
param1 | val is value. |
float leClampf | ( | float | min, |
float | max, | ||
float | f | ||
) |
Calculate clamp of a float.
Calculates the clamp value of i constrained to the range min to max.
param1 | min is an float. |
param2 | max is an float. |
param3 | f is an float. |
int32_t leClampi | ( | int32_t | min, |
int32_t | max, | ||
int32_t | i | ||
) |
Calculates clamp of an integer.
Calculates the clamp value of i constrained to the range min to max.
param1 | min is an integer. |
param2 | max is an integer. |
param3 | i is an integer. |
int32_t leCos | ( | int32_t | v | ) |
Calculate cosine of a number.
Calculates cosine of angle.
param1 | v is the value in degrees. |
int32_t leDivideRounding | ( | int32_t | num, |
int32_t | denom | ||
) |
Performs a linear interpolation of an integer based on a percentage between two signed points.
Calculates integer division of num divided by denom.
param1 | num is an integer. |
param2 | denom is the denom. |
param3 | per is the percent to apply. |
Calculates points in an arc.
Help
Generates points in an arc at radius and angle.
param1 | startAngleArc0 is point to rotate. |
param2 | endAngleArc0 of the rotation. |
param2 | dir of the rotation. |
param2 | quadrant of the rotation. |
Project point.
Project point p1 onto p2 on y coordinate.
param1 | p1 is point to rotate. |
param2 | p2 of the rotation. |
param3 | y is the angle in degrees. |
Project Y give X.
Project point p1 onto p2 on x coordinate.
param1 | p1 is point to rotate. |
param2 | p2 of the rotation. |
param3 | x is the angle in degrees. |
int32_t leLerp | ( | int32_t | x, |
int32_t | y, | ||
uint32_t | per | ||
) |
Calculates a linear interpolation of an integer based on a percentage between two signed points.
Calculates a linear interpolation between x and y based on per.
param1 | x is point. |
param2 | y is point. |
param2 | per is the percent to apply. |
float leMaxf | ( | float | l, |
float | r | ||
) |
Calculate maximum of two floats.
Calculates the maximum of two floats l and r.
param1 | l is an float. |
param2 | r is an float. |
int32_t leMaxi | ( | int32_t | l, |
int32_t | r | ||
) |
Calculate maximum of two integers.
Calculates the maximum of integers l and r.
param1 | l is an integer. |
param2 | r is an integer. |
float leMinf | ( | float | l, |
float | r | ||
) |
Calculate minimum of two floats.
Calculates the minimum of two floats l and r.
param1 | l is an float. |
param2 | r is an float. |
int32_t leMini | ( | int32_t | l, |
int32_t | r | ||
) |
Calculate minimum of two integers.
Calculates the lessor of integers l and r.
param1 | l is an integer. |
param2 | r is an integer. |
int32_t leNormalizeAngle | ( | int32_t | t | ) |
Normalize an angle between 0 - 360.
Normalizes angle. Example: t = -5, return value is 355 t = 450, return value is 90
param1 | x is an integer. |
param2 | y is the percent to apply. |
param2 | per is the percent to apply. |
uint32_t lePercent | ( | uint32_t | l, |
uint32_t | r | ||
) |
Calculate percent of number.
Calculates the decimal percent of l and r. Integer based. Accuracy for higher numbers is not guaranteed.The result is the decimal percentage multiplied by 100.
param1 | l is an integer. |
param2 | r is an integer. |
uint32_t lePercentOf | ( | uint32_t | num, |
uint32_t | percent | ||
) |
Calculate percent of a number.
Calculate the whole number percentage of num and percent.
param1 | num is an integer. |
param2 | percent is the percent to apply. |
void lePercentOfDec | ( | uint32_t | num, |
uint32_t | percent, | ||
uint32_t * | whl, | ||
uint32_t * | dec | ||
) |
Calculate percent of a decimal.
Calculates the whole number percent of num and percent and stores the result in whl and dec
param1 | l is an integer. |
param2 | percent is the percent to apply. |
uint32_t lePercentWholeRounded | ( | uint32_t | l, |
uint32_t | r | ||
) |
Calculate percent whole rounded.
Calculates the whole number integer based percent of l and r. The difference between this and lePercent is that the decimal portion of the whole number is rounded off.
param1 | l is an integer. |
param2 | r is an integer. |
Generate points in an arc.
Generates points in an arc using radius and angle.
param1 | radius is the radius of arc. |
param2 | angle is the angle of arc. |
param3 | points is the position to query. |
Calculate bounding rectangle.
Calculates the bounding rectangle for the area rect rotated about origin at angle.
rect | area to rotate. |
ang | the angle in degrees. |
res | the resultant rectangle |
Rotates point.
Rotates point around origin at angle degrees.
param1 | point is point to rotate. |
param2 | origin of the rotation. |
param3 | angle is the angle in degrees. |
param4 | the resulting point |
uint32_t leScaleInteger | ( | uint32_t | num, |
uint32_t | oldMax, | ||
uint32_t | newMax | ||
) |
Calculate the scale of an integer.
Calculates the scale of num from oldMax to newMax
param1 | num is an integer. |
param2 | oldMax is the old range maximum. |
param3 | newMax is the new range maximum. |
int32_t leScaleIntegerSigned | ( | int32_t | num, |
int32_t | oldMax, | ||
int32_t | newMax | ||
) |
Calculate the scale of signed integer.
Calculates the scale of num in range oldMax to range newMax.
param1 | num is an integer. |
param2 | oldMax is an integer. |
param3 | newMax is the percent to apply. |
int32_t leSin | ( | int32_t | v | ) |
Calculate sin of a number.
Calculates sin of angle.
param1 | v is the value in degrees. |
Sorts two points on the X axis.
Sort points p1 and p2 on the X axis.
param1 | p1 is point. |
param2 | p2 is point. |
Sorts two points on the Y axis.
Sort points p1 and p2 on the Y axis.
param1 | p1 is a point. |
param2 | p2 is a point. |