Geodle #34
Hint
#pragma once
#ifndef [********]_GPOINT_HPP
#define [********]_GPOINT_HPP
#include <Geode/cocos/cocoa/CCGeometry.h>
struct GPoint {
double x;
double y;
constexpr GPoint(const double x, const double y) : x(x), y(y) {}
explicit constexpr GPoint(const cocos2d::CCPoint& point) : x(point.x), y(point.y) {}
double constexpr dot(const GPoint& other) const {
return other.x * x + other.y * y;
}
double constexpr magnitude() const {
return std::sqrt(dot(*this));
}
GPoint constexpr unit() const {
double d = std::sqrt(dot(*this));
return GPoint(x / d, y / d);
}