ProtoTracer  1.0
Real-time 3D rendering and animation engine
Loading...
Searching...
No Matches
Shape Class Referenceabstract

Abstract base class for 2D geometric shapes. More...

#include <Shape.h>

Inheritance diagram for Shape:
Collaboration diagram for Shape:

Public Member Functions

 Shape (Vector2D center, Vector2D size, float rotation)
 Constructs a Shape object with specified center, size, and rotation.
 
void SetCenter (Vector2D center)
 Sets the center of the shape.
 
void Translate (Vector2D offset)
 Translates the shape by a given offset.
 
Vector2D GetCenter ()
 Gets the center point of the shape.
 
void SetSize (Vector2D size)
 Sets the size of the shape.
 
void Scale (Vector2D scale)
 Scales the shape by a given factor.
 
Vector2D GetSize ()
 Gets the size of the shape.
 
void SetRotation (float rotation)
 Sets the rotation angle of the shape.
 
void Rotate (float offset)
 Rotates the shape by a given offset angle.
 
float GetRotation ()
 Gets the current rotation angle of the shape.
 
virtual bool IsInShape (Vector2D point)=0
 Checks if a given point lies within the shape's boundaries.
 

Protected Attributes

Vector2D center
 The center point of the shape.
 
Vector2D size
 The size of the shape, large enough to fit within a bounding rectangle.
 
float rotation
 The rotation of the shape in degrees.
 

Detailed Description

Abstract base class for 2D geometric shapes.

Definition at line 22 of file Shape.h.

Constructor & Destructor Documentation

◆ Shape()

Shape ( Vector2D  center,
Vector2D  size,
float  rotation 
)

Constructs a Shape object with specified center, size, and rotation.

Parameters
centerCenter point of the shape.
sizeDimensions of the shape.
rotationRotation angle in degrees.

Definition at line 3 of file Shape.cpp.

Member Function Documentation

◆ GetCenter()

Vector2D GetCenter ( )

Gets the center point of the shape.

Returns
The center point of the shape.

Definition at line 15 of file Shape.cpp.

References center.

◆ GetRotation()

float GetRotation ( )

Gets the current rotation angle of the shape.

Returns
The rotation angle in degrees.

Definition at line 39 of file Shape.cpp.

References rotation.

◆ GetSize()

Vector2D GetSize ( )

Gets the size of the shape.

Returns
The size of the shape.

Definition at line 27 of file Shape.cpp.

References size.

◆ IsInShape()

virtual bool IsInShape ( Vector2D  point)
pure virtual

Checks if a given point lies within the shape's boundaries.

Parameters
pointThe point to check.
Returns
True if the point is within the shape, otherwise false.

Implemented in Circle, Ellipse, and Rectangle.

Referenced by MaterialMask::GetRGB().

◆ Rotate()

void Rotate ( float  offset)

Rotates the shape by a given offset angle.

Parameters
offsetOffset angle in degrees.

Definition at line 35 of file Shape.cpp.

References rotation.

◆ Scale()

void Scale ( Vector2D  scale)

Scales the shape by a given factor.

Parameters
scaleScale factor for the shape dimensions.

Definition at line 23 of file Shape.cpp.

References size.

◆ SetCenter()

void SetCenter ( Vector2D  center)

Sets the center of the shape.

Parameters
centerNew center point.

Definition at line 7 of file Shape.cpp.

References center.

◆ SetRotation()

void SetRotation ( float  rotation)

Sets the rotation angle of the shape.

Parameters
rotationNew rotation angle in degrees.

Definition at line 31 of file Shape.cpp.

References rotation.

◆ SetSize()

void SetSize ( Vector2D  size)

Sets the size of the shape.

Parameters
sizeNew dimensions of the shape.

Definition at line 19 of file Shape.cpp.

References size.

◆ Translate()

void Translate ( Vector2D  offset)

Translates the shape by a given offset.

Parameters
offsetOffset vector to translate the shape.

Definition at line 11 of file Shape.cpp.

References center.

Member Data Documentation

◆ center

Vector2D center
protected

The center point of the shape.

Definition at line 24 of file Shape.h.

Referenced by GetCenter(), Circle::IsInShape(), Ellipse::IsInShape(), Rectangle::IsInShape(), SetCenter(), and Translate().

◆ rotation

float rotation
protected

The rotation of the shape in degrees.

Definition at line 26 of file Shape.h.

Referenced by GetRotation(), Ellipse::IsInShape(), Rectangle::IsInShape(), Rotate(), and SetRotation().

◆ size

Vector2D size
protected

The size of the shape, large enough to fit within a bounding rectangle.

Definition at line 25 of file Shape.h.

Referenced by GetSize(), Ellipse::IsInShape(), Rectangle::IsInShape(), Scale(), and SetSize().


The documentation for this class was generated from the following files: