ProtoTracer  1.0
Real-time 3D rendering and animation engine
Loading...
Searching...
No Matches
Ellipse.cpp
Go to the documentation of this file.
1#include "Ellipse.h"
2
3Ellipse::Ellipse(Vector2D center, Vector2D size, float rotation) : Shape(center, size / 2.0f, rotation) {}
4
6 float x = (point.X - center.X);
7 float y = (point.Y - center.Y);
8
9 float sinR = sinf(rotation * Mathematics::MPID180);
10 float cosR = cosf(rotation * Mathematics::MPID180);
11
12 float xP = x * cosR - y * sinR; // rotate about center
13 float yP = y * cosR + x * sinR; // rotate about center
14
15 float xQuot = xP * xP / (size.X * size.X); // size is twice radius
16 float yQuot = yP * yP / (size.Y * size.Y);
17
18 return xQuot + yQuot < 1.0f;
19}
Defines the Ellipse class for representing elliptical shapes in 2D space.
Ellipse(Vector2D center, Vector2D size, float rotation)
Constructs an Ellipse object with specified center, size, and rotation.
Definition Ellipse.cpp:3
bool IsInShape(Vector2D point) override
Checks if a given point lies within the ellipse's boundaries.
Definition Ellipse.cpp:5
static const float MPID180
The value of , useful for converting degrees to radians.
Definition Mathematics.h:47
Abstract base class for 2D geometric shapes.
Definition Shape.h:22
float rotation
The rotation of the shape in degrees.
Definition Shape.h:26
Vector2D center
The center point of the shape.
Definition Shape.h:24
Vector2D size
The size of the shape, large enough to fit within a bounding rectangle.
Definition Shape.h:25
Represents a 2D vector (X, Y) and provides methods for vector arithmetic.
Definition Vector2D.h:27
float X
The X-component of the 2D vector.
Definition Vector2D.h:29
float Y
The Y-component of the 2D vector.
Definition Vector2D.h:30