Lamp-Da 0.1
A compact lantern project
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
lampda::modes::Particle Struct Reference

Define a particle in 3D space. it has a position and speed. More...

#include <particle.hpp>

Public Member Functions

 Particle ()=default
 Default particle init.
 
 Particle (const Particle &other)=default
 Copy constructor for a particle.
 
 Particle (const utils::vec3d &positionCartesian)
 Construct a Particle from a 3D cartesian position.
 
 Particle (const float positionTheta_rad, const float positionZ_mm)
 Construct a particle from an angle and height.
 
utils::vec2d compute_speed_increment (const utils::vec3d &accelerationCartesian_m, const float deltaTime_s) const
 Compute the speed increment in the constraint lamp body.
 
utils::vec2d update_speed (const utils::vec3d &accelerationCartesian_m, const float deltaTime_s)
 Dampen the speed and apply a cartesian acceleration to it, without moving the particle.
 
void apply_acceleration (const utils::vec3d &accelerationCartesian_m, const float deltaTime_s, const bool shouldContrain=true)
 apply a cartesian acceleration to this particulate
 
Particle simulate_after_acceleration (const utils::vec3d &accelerationCartesian_m, const float deltaTime_s, const bool shouldContrain=true) const
 Simulate this particle movement as a new particle.
 
void constraint_into_lamp_body ()
 Contrain the particle movement to the cylinder, limiting the movement at the extremities.
 
void dampen_speed (const float dampenFactor)
 Bleed off some speed. Simulate a dampening factor (like friction loss)
 
void set_color (const uint32_t color)
 
uint32_t get_color () const
 
uint16_t to_lamp_index () const
 Convert this particle coordinates to a constraint lamp index.
 
int16_t to_lamp_index_no_bounds () const
 Convert this particle coordinates to an unconstraint lamp index: the nearest led of the helix.
 
int16_t led_index_at_offset (const utils::vec2d &offset_mm) const
 Return the led under this particle, once moved by an offset on the cylinder surface (in mm).
 
utils::vec2d get_surface_speed () const
 Return the speed on the cylinder surface, in mm/s (around the tube, along the height)
 
void move_by (const utils::vec2d &offset_mm, const int16_t ledIndex)
 Move this particle on the cylinder surface, to a led already computed from this offset.
 

Static Public Member Functions

static int16_t led_index_at (const float positionTheta_rad, const float positionZ_mm)
 Find the led nearest to a position, following the real helix of the strip. A led height depends on its angle: choosing the turn from the height alone would be up to a full row wrong.
 
static float potential_at_led (const utils::vec3d &accelerationCartesian_m, const int16_t ledIndex)
 Potential energy of a led under an acceleration, consistent with the acceleration of a particle.
 

Public Attributes

float thetaSpeed_radS = 0.0f
 angular speed, in radian/seconds
 
float zSpeed_mS = 0.0f
 linear speed, in meter/seconds
 
float theta_rad = 0.0f
 position, in radians
 
float z_mm = 0.0f
 height, in millimeters.
 
int16_t _savedLampIndex
 optimization
 

Detailed Description

Define a particle in 3D space. it has a position and speed.

Member Function Documentation

◆ apply_acceleration()

void lampda::modes::Particle::apply_acceleration ( const utils::vec3d &  accelerationCartesian_m,
const float  deltaTime_s,
const bool  shouldContrain = true 
)
inline

apply a cartesian acceleration to this particulate

Parameters
[in]accelerationCartesian_mAcceleration applied at this update
[in]deltaTime_sTime since the latest update
[in]shouldContrainIf true, will constrain the movement into the lamp body.

◆ compute_speed_increment()

utils::vec2d lampda::modes::Particle::compute_speed_increment ( const utils::vec3d &  accelerationCartesian_m,
const float  deltaTime_s 
) const
inline

Compute the speed increment in the constraint lamp body.

Parameters
[in]accelerationCartesian_mAcceleration applied at this update
[in]deltaTime_sTime since the latest update
Returns
The speed in angle and heigh.

◆ led_index_at()

static int16_t lampda::modes::Particle::led_index_at ( const float  positionTheta_rad,
const float  positionZ_mm 
)
inlinestatic

Find the led nearest to a position, following the real helix of the strip. A led height depends on its angle: choosing the turn from the height alone would be up to a full row wrong.

Parameters
[in]positionTheta_radAngle of the position, in radians.
[in]positionZ_mmHeight of the position, in millimeters.
Returns
The index of the led. It is not necessarly a valid index.

◆ potential_at_led()

static float lampda::modes::Particle::potential_at_led ( const utils::vec3d &  accelerationCartesian_m,
const int16_t  ledIndex 
)
inlinestatic

Potential energy of a led under an acceleration, consistent with the acceleration of a particle.

Parameters
[in]accelerationCartesian_mAcceleration applied at this update
[in]ledIndexIndex of the led. It can be out of the strip.
Returns
The potential (a particle is accelerated toward the leds with a lower one), in mm.m/s^2

◆ simulate_after_acceleration()

Particle lampda::modes::Particle::simulate_after_acceleration ( const utils::vec3d &  accelerationCartesian_m,
const float  deltaTime_s,
const bool  shouldContrain = true 
) const
inline

Simulate this particle movement as a new particle.

Parameters
[in]accelerationCartesian_mAcceleration applied at this update
[in]deltaTime_sTime since the latest update
[in]shouldContrainIf true, will constrain the movement into the lamp body.

◆ update_speed()

utils::vec2d lampda::modes::Particle::update_speed ( const utils::vec3d &  accelerationCartesian_m,
const float  deltaTime_s 
)
inline

Dampen the speed and apply a cartesian acceleration to it, without moving the particle.

Parameters
[in]accelerationCartesian_mAcceleration applied at this update
[in]deltaTime_sTime since the latest update
Returns
The speed gained at this update, on the cylinder surface, in mm/s (around the tube, along the height)

The documentation for this struct was generated from the following file: