MCPcopy Create free account
hub / github.com/FastLED/FastLED / transform

Method transform

src/fl/math/transform.cpp.hpp:16–43  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14namespace fl {
15
16vec2f TransformFloatImpl::transform(const vec2f &xy) const {
17 if (is_identity()) {
18 return xy;
19 }
20 float x = xy.x;
21 float y = xy.y;
22 if (scale_x != 1.0f) {
23 x *= scale_x;
24 }
25 if (scale_y != 1.0f) {
26 y *= scale_y;
27 }
28 // Assume that adding floats is fast when offset_x == 0.0f
29 x += offset_x;
30 y += offset_y;
31
32 const bool has_rotation = (rotation != 0.0f);
33
34 if (has_rotation) {
35 float radians = rotation * 2 * FL_PI;
36 float cos_theta = cosf(radians);
37 float sin_theta = sinf(radians);
38 float x_rotated = x * cos_theta - y * sin_theta;
39 float y_rotated = x * sin_theta + y * cos_theta;
40 return vec2f(x_rotated, y_rotated);
41 }
42 return vec2f(x, y);
43}
44
45Transform16 Transform16::ToBounds(alpha16 max_value) {
46 Transform16 tx;

Callers 3

xypath.cpp.hppFile · 0.45
compute_floatMethod · 0.45
FL_TEST_FILEFunction · 0.45

Calls 7

cosfFunction · 0.85
sinfFunction · 0.85
alpha16Class · 0.85
map32_to_16Function · 0.85
cos16Function · 0.50
sin16Function · 0.50
u32Enum · 0.50

Tested by

no test coverage detected