From c6341d2bfc9d5a1c9007e6ae6f48a77390a7415b Mon Sep 17 00:00:00 2001 From: Frank DeMarco Date: Sun, 6 Sep 2020 16:05:19 -0400 Subject: [PATCH] added get point on circle function --- demo/Demo.cpp | 10 +++++----- src/extension.cpp | 7 +++++++ src/extension.hpp | 1 + 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/demo/Demo.cpp b/demo/Demo.cpp index 80d336f..a236b8a 100644 --- a/demo/Demo.cpp +++ b/demo/Demo.cpp @@ -9,11 +9,11 @@ point coordinates, relative coordinates, relative lengths, relative sizes, delta time, specify config parameters on command line, effects chain, asset dict with metadata, move added sprite locations by offset when location is - changed, gradients, level select code input, logging, variable screen - resolution, debug display, loading wheel animation, shadowed sprite, separate - update and draw, sprite movement cage, multiple windows, multiple renderers, - node children list, node animations list, copy constructor for all base - classes, private and public class members, pixel class iterator, sprite + changed, gradients, level select code input, log to stdout and file, variable + screen resolution, debug display, loading wheel animation, shadowed sprite, + separate update and draw, sprite movement cage, multiple windows, multiple + renderers, node children list, node animations list, copy constructor for all + base classes, private and public class members, pixel class iterator, sprite movement history, input history, use seconds instead of milliseconds, store a node's animations in list, frame object for sprite class, inline short functions, add box2d to library, load in separate thread and display progress diff --git a/src/extension.cpp b/src/extension.cpp index 8f107f3..97e56e7 100644 --- a/src/extension.cpp +++ b/src/extension.cpp @@ -1,3 +1,5 @@ +#include + #include "sdl2-gfx/SDL2_gfxPrimitives.h" #include "Pixels.hpp" @@ -8,6 +10,11 @@ void sfw::set_magnitude(glm::vec2& vector, float magnitude) vector = glm::normalize(vector) * magnitude; } +glm::vec2 sfw::get_point_on_circle(const glm::vec2& center, float radius, float angle) +{ + return {center.x + std::sin(angle) * radius, center.y - std::cos(angle) * radius}; +} + Box sfw::get_texture_box(SDL_Texture* texture) { int width, height; diff --git a/src/extension.hpp b/src/extension.hpp index 8bdfd11..42f0261 100644 --- a/src/extension.hpp +++ b/src/extension.hpp @@ -34,6 +34,7 @@ namespace sfw enum scaler {scale2x, xbr}; void set_magnitude(glm::vec2&, float); + glm::vec2 get_point_on_circle(const glm::vec2&, float, float); Box get_texture_box(SDL_Texture*); glm::vec2 fit_and_preserve_aspect(const glm::vec2&, const glm::vec2&); std::vector> get_blinds_boxes(glm::vec2, float = 0.05f, int = 4);