colors, rotations, and more

This commit is contained in:
2024-10-11 00:58:24 -04:00
parent e29f27266a
commit 823a8f79d3
9 changed files with 367 additions and 149 deletions

View File

@@ -0,0 +1,33 @@
// single point rotation
rotate :: (p: *Vec2s64, center: Vec2s64, angle: s64) {
rad := cast(float64)angle * (PI / 180.0);
// translate to center
tx := p.x - center.x;
ty := p.y - center.y;
// apply rotation
rx := cast(s64)(tx * cos(rad) - ty * sin(rad));
ry := cast(s64)(tx * sin(rad) + ty * cos(rad));
// translate back
p.x = rx + center.x;
p.y = ry + center.y;
}
// rotate n points
rotate :: (pn: ..*Vec2s64, center: Vec2s64, angle: s64) {
for pn {
rotate(it, center, angle);
}
}
// rotate 3 points via triangle struct
rotate :: (t: *Triangle, center: Vec2s64, angle: s64) {
rotate(*t.p1, *t.p2, *t.p3, center = center, angle = angle);
}
// rotate 4 points via quad struct
rotate :: (q: *Quad, center: Vec2s64, angle: s64) {
rotate(*q.p1, *q.p2, *q.p3, *q.p4, center = center, angle = angle);
}