INFO702 - TPs
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
LogicalScene Struct Reference

A class to store master shapes and to test their possible collisions with a randomized algorithm. More...

#include <objects.hpp>

Public Member Functions

 LogicalScene (int n)
 
bool intersect (MasterShape *f1, MasterShape *f2)
 
bool intersect (MasterShape *f1)
 

Public Attributes

std::vector< MasterShape * > formes
 
int nb_tested
 

Detailed Description

A class to store master shapes and to test their possible collisions with a randomized algorithm.

Definition at line 89 of file objects.hpp.

Constructor & Destructor Documentation

◆ LogicalScene()

LogicalScene::LogicalScene ( int  n)

Builds a logical scene where collisions are detected by checking n random points within shapes.

Parameters
nany positive integer.

Definition at line 186 of file objects.cpp.

187 : nb_tested( n ) {}

Member Function Documentation

◆ intersect() [1/2]

bool LogicalScene::intersect ( MasterShape f1)
Parameters
f1any master shape.
Returns
'true' iff it collides with a different master shape stored in this logical scene.

Definition at line 202 of file objects.cpp.

203{
204 for ( auto f : formes )
205 if ( ( f != f1 ) && intersect( f, f1 ) )
206 return true;
207 return false;
208}
bool intersect(MasterShape *f1, MasterShape *f2)
Definition objects.cpp:190

◆ intersect() [2/2]

bool LogicalScene::intersect ( MasterShape f1,
MasterShape f2 
)

Given two shapes f1 and f2, returns if they collide.

Parameters
f1any master shape.
f2any different master shape.
Returns
'true' iff they collide, i.e. have a common intersection.

Definition at line 190 of file objects.cpp.

191{
192 for ( int i = 0; i < nb_tested; ++i )
193 {
194 if ( f2->isInside( f1->randomPoint() )
195 || f1->isInside( f2->randomPoint() ) )
196 return true;
197 }
198 return false;
199}

Member Data Documentation

◆ formes

std::vector< MasterShape*> LogicalScene::formes

Definition at line 90 of file objects.hpp.

◆ nb_tested

int LogicalScene::nb_tested

Definition at line 91 of file objects.hpp.


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