Wavelength
Privacy-focused, cross-platform, and open-source communication application
Loading...
Searching...
No Matches
BlobMath Class Reference

Provides static utility functions for mathematical operations related to the Blob animation. More...

#include <blob_math.h>

Collaboration diagram for BlobMath:

Static Public Member Functions

static QPointF CalculateBezierControlPoint (const QPointF &p0, const QPointF &p1, const QPointF &p2, float tension)
 Calculates a control point for a cubic Bezier segment, often used in Catmull-Rom splines. This helps create smooth curves that pass through a series of points (p0, p1, p2, ...). The calculated point is a control point associated with the segment passing through p1.
 
template<typename T>
requires std::totally_ordered<T>
static T Clamp (const T &value, const T &min, const T &max)
 Clamps a value between a minimum and maximum limit. Requires the type T to be totally ordered (support <, >, <=, >=, ==, !=). Uses Qt's qBound internally.
 
static std::vector< QPointF > GenerateCircularPoints (const QPointF &center, double radius, int num_of_points)
 Generates a specified number of points approximately distributed on a circle. Introduces slight randomness to the radius of each point for a more organic look.
 
static bool IsValidPoint (const QPointF &point)
 Checks if a QPointF contains valid coordinate values. Verifies that coordinates are not NaN, infinite, or excessively large.
 

Detailed Description

Provides static utility functions for mathematical operations related to the Blob animation.

This class contains helper functions for tasks such as validating points, clamping values, generating points on a circle, and calculating Bezier control points (potentially for path smoothing).

Member Function Documentation

◆ CalculateBezierControlPoint()

QPointF BlobMath::CalculateBezierControlPoint ( const QPointF & p0,
const QPointF & p1,
const QPointF & p2,
float tension )
static

Calculates a control point for a cubic Bezier segment, often used in Catmull-Rom splines. This helps create smooth curves that pass through a series of points (p0, p1, p2, ...). The calculated point is a control point associated with the segment passing through p1.

Parameters
p0The point before the segment's start point.
p1The start point of the curve segment.
p2The end point of the curve segment.
tensionControls the "tightness" of the curve. Typically, 0.5 for Catmull-Rom.
Returns
The calculated control point QPointF.

◆ Clamp()

template<typename T>
requires std::totally_ordered<T>
static T BlobMath::Clamp ( const T & value,
const T & min,
const T & max )
inlinestatic

Clamps a value between a minimum and maximum limit. Requires the type T to be totally ordered (support <, >, <=, >=, ==, !=). Uses Qt's qBound internally.

Template Parameters
TThe type of the value to clamp. Must satisfy std::totally_ordered.
Parameters
valueThe value to clamp.
minThe minimum allowed value.
maxThe maximum allowed value.
Returns
The clamped value, guaranteed to be within [min, max].
Here is the caller graph for this function:

◆ GenerateCircularPoints()

std::vector< QPointF > BlobMath::GenerateCircularPoints ( const QPointF & center,
double radius,
int num_of_points )
static

Generates a specified number of points approximately distributed on a circle. Introduces slight randomness to the radius of each point for a more organic look.

Parameters
centerThe center of the circle.
radiusThe base radius of the circle.
num_of_pointsThe number of points to generate.
Returns
A std::vector<QPointF> containing the generated points.
Here is the caller graph for this function:

◆ IsValidPoint()

bool BlobMath::IsValidPoint ( const QPointF & point)
static

Checks if a QPointF contains valid coordinate values. Verifies that coordinates are not NaN, infinite, or excessively large.

Parameters
pointThe QPointF to validate.
Returns
True if the point is valid, false otherwise.
Here is the caller graph for this function:

The documentation for this class was generated from the following files: