move transformations into single file

This commit is contained in:
2025-06-30 09:36:36 -04:00
parent be43704a64
commit 13d5944e2a
6 changed files with 41 additions and 55 deletions

View File

@@ -105,9 +105,7 @@ maybe_resize_screen :: (screen: *Screen) {
}
#load "draw.jai";
#load "rotate.jai";
#load "scale.jai";
#load "translate.jai";
#load "transform.jai";
#load "file_operations.jai";
#load "console.jai";
#load "math_extras.jai";

View File

@@ -1,14 +0,0 @@
scale :: (factor: Vector2, pn: ..*Vec2s64) {
for pn {
it.x = cast(s64)(it.x * factor.x);
it.y = cast(s64)(it.y * factor.y);
}
}
scale :: (factor: Vector2, t: *Triangle) {
scale(factor, *t.p1, *t.p2, *t.p3);
}
scale :: (factor: Vector2, q: *Quad) {
scale(factor, *q.p1, *q.p2, *q.p3, *q.p4);
}

View File

@@ -1,3 +1,22 @@
// for n points
translate :: (amount: Vec2s64, pn: ..*Vec2s64) {
for pn {
it.x += amount.x;
it.y += amount.y;
}
}
// for a triangle
translate :: (amount: Vec2s64, t: *Triangle) {
translate(amount, *t.p1, *t.p2, *t.p3);
}
// for a quad
translate :: (amount: Vec2s64, q: *Quad) {
translate(amount, *q.p1, *q.p2, *q.p3, *q.p4);
}
// single point rotation
rotate :: (angle: s64, center: Vec2s64, p: *Vec2s64) {
rad := cast(float64)angle * (PI / 180.0);
@@ -30,4 +49,19 @@ rotate :: (angle: s64, center: Vec2s64, t: *Triangle) {
// rotate 4 points via quad struct
rotate :: (angle: s64, center: Vec2s64, q: *Quad) {
rotate(angle, center, *q.p1, *q.p2, *q.p3, *q.p4);
}
scale :: (factor: Vector2, pn: ..*Vec2s64) {
for pn {
it.x = cast(s64)(it.x * factor.x);
it.y = cast(s64)(it.y * factor.y);
}
}
scale :: (factor: Vector2, t: *Triangle) {
scale(factor, *t.p1, *t.p2, *t.p3);
}
scale :: (factor: Vector2, q: *Quad) {
scale(factor, *q.p1, *q.p2, *q.p3, *q.p4);
}

View File

@@ -1,18 +0,0 @@
// for n points
translate :: (amount: Vec2s64, pn: ..*Vec2s64) {
for pn {
it.x += amount.x;
it.y += amount.y;
}
}
// for a triangle
translate :: (amount: Vec2s64, t: *Triangle) {
translate(amount, *t.p1, *t.p2, *t.p3);
}
// for a quad
translate :: (amount: Vec2s64, q: *Quad) {
translate(amount, *q.p1, *q.p2, *q.p3, *q.p4);
}