Skip to content

Commit

Permalink
Updated examples which use Mat3::rotation
Browse files Browse the repository at this point in the history
  • Loading branch information
ThePythonator committed Aug 22, 2022
1 parent 03dd4f5 commit b931dc2
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions 32blit/graphics/mode7.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ namespace blit {
Vec2 v(w - pos);
v.normalize();
Vec2 f(0, -1);
f *= Mat3::rotation(angle);
f *= Mat3::rotation(-angle);

float wd = (w - pos).length();
float dot = f.dot(v);
Expand Down Expand Up @@ -72,7 +72,7 @@ namespace blit {
*/
Vec2 screen_to_world(Vec2 s, float fov, float angle, Vec2 pos, float near, float far, Rect viewport) {
Vec2 forward(0, -1);
forward *= Mat3::rotation(angle);
forward *= Mat3::rotation(-angle);

Vec2 left = forward;
left *= Mat3::rotation((fov / 2.0f));
Expand Down
6 changes: 3 additions & 3 deletions examples/flight/flight.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ std::vector<DrawObject> drawObjects (std::vector<object> objects) {
Vec2 vo = (o.pos - pos);
vo.normalize();
Vec2 forward(0, -1);
forward *= Mat3::rotation(angle);
forward *= Mat3::rotation(-angle);

// TODO: provide a "is_point_in_frustrum" check
if(forward.dot(vo) > 0) { // check if object is in front of us
Expand Down Expand Up @@ -223,7 +223,7 @@ void render(uint32_t time_ms) {
screen.pixel(mtpos);

Vec2 forward(0, -10);
forward *= Mat3::rotation(angle);
forward *= Mat3::rotation(-angle);
screen.pen = Pen(255, 255, 255, 100);
screen.line(mmpos, mmpos + forward);

Expand Down Expand Up @@ -282,7 +282,7 @@ void update(uint32_t time) {
}

angle += deg2rad(angle_delta);
Mat3 r = Mat3::rotation(angle);
Mat3 r = Mat3::rotation(-angle);
pos = pos - (vel * r);

if (pressed(Button::A) || (joystick.y > 0.0f)) {
Expand Down
2 changes: 1 addition & 1 deletion examples/geometry/geometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ std::vector<Vec2> random_convex_polygon(Vec2 origin, float radius) {
void rotate_polygon(std::vector<Vec2> &points, float angle, Vec2 origin) {
Mat3 t = Mat3::identity();
t *= Mat3::translation(origin);
t *= Mat3::rotation(angle);
t *= Mat3::rotation(-angle);
t *= Mat3::translation(-origin);
for (auto &p : points) {
p *= t;
Expand Down

0 comments on commit b931dc2

Please sign in to comment.