Skip to content
jsutlive edited this page Jun 13, 2023 · 1 revision

#Mesh abstract class

extends N/A

implements N/A

Introduction

Mesh is a component which is used to describe the physical boundary of a physics entity which is a complex shape. A mesh is described as a list of nodes and the edges used to connect them. A mesh must be built in a clockwise or counter-clockwise order in order to ensure proper calculation of area as well as collision detection.

Fields

Accessibility Type Field Name Description
private List nodes Nodes(vertices) making up the mesh. Must be in clockwise/counter-clockwise order
private List edges Used to describe the connection between two nodes. May be used to abstract some physics functions.

Methods

Accessibility Return Type Method Name Description
public boolean collidesWithPoint determine if a node is within the edge
public void containsPoint determines if a node or a node with a position exists in this mesh
public Vector2f calculateCentroid returns the centroid of the mesh
public float getArea returns area of the mesh
public float getPerimeter returns the perimeter of the mesh

Physics/ Mathematics

Shoelace theorem for area calculation

Example in progress. See this link for an explanation of shoelace formula.

Collision detection

Example in progress, see link for an explanation of collision detection algorithm.

Clone this wiki locally