FastLED 3.9.15
Loading...
Searching...
No Matches

◆ transform()

vec2f fl::TransformFloatImpl::transform ( const vec2f & xy) const

Definition at line 15 of file transform.cpp.

15 {
16 if (is_identity()) {
17 return xy;
18 }
19 float x = xy.x;
20 float y = xy.y;
21 if (scale_x != 1.0f) {
22 x *= scale_x;
23 }
24 if (scale_y != 1.0f) {
25 y *= scale_y;
26 }
27 // Assume that adding floats is fast when offset_x == 0.0f
28 x += offset_x;
29 y += offset_y;
30
31 const bool has_rotation = (rotation != 0.0f);
32
33 if (has_rotation) {
34 float radians = rotation * 2 * PI;
35 float cos_theta = cosf(radians);
36 float sin_theta = sinf(radians);
37 float x_rotated = x * cos_theta - y * sin_theta;
38 float y_rotated = x * sin_theta + y * cos_theta;
39 return vec2f(x_rotated, y_rotated);
40 }
41 return vec2f(x, y);
42}
uint32_t x[NUM_LAYERS]
Definition Fire2023.ino:82
uint32_t y[NUM_LAYERS]
Definition Fire2023.ino:83
unsigned int xy(unsigned int x, unsigned int y)
bool is_identity() const
#define PI
Definition math_macros.h:57
vec2< float > vec2f
Definition geometry.h:151

References is_identity(), offset_x, offset_y, PI, rotation, scale_x, scale_y, x, xy(), and y.

+ Here is the call graph for this function: