Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ronan
coraMaths
Commits
433de40e
Commit
433de40e
authored
Jun 05, 2016
by
ronan
Browse files
Add optimised circle detection
parent
3a038543
Pipeline
#2252
passed with stage
in 59 seconds
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
cora/cora-maths/1.0/cora-maths-1.0-javadoc.jar
View file @
433de40e
No preview for this file type
cora/cora-maths/1.0/cora-maths-1.0-sources.jar
View file @
433de40e
No preview for this file type
cora/cora-maths/1.0/cora-maths-1.0.jar
View file @
433de40e
No preview for this file type
src/main/java/org/cora/maths/collision/CollisionDetector.java
View file @
433de40e
package
org.cora.maths.collision
;
import
org.cora.maths.FloatA
;
import
org.cora.maths.Form
;
import
org.cora.maths.Matrix2
;
import
org.cora.maths.Vector2D
;
import
org.cora.maths.*
;
import
java.util.ArrayList
;
/**
* Tools to detect collision between two convex polygons
* Tools to detect collision between two convex polygons
and taking account of velocity
*/
public
class
CollisionDetector
{
/**
*
*
Detect collision
* @param A test form A
* @param B test form B
* @param VA velocity of object A
...
...
@@ -28,6 +25,24 @@ public class CollisionDetector
return
collisionSat
(
A
,
B
,
VA
,
VB
,
push
,
t
);
}
/**
* Detect collision with circle optimisiation detection
* @param A test form A
* @param B test form B
* @param cA circle containing A
* @param cB circle containing B
* @param VA velocity of object A
* @param VB velocity of object B
* @param push a blank vector to store the penetration vector
* @param t a blank float to store the result of amount of penetration
* @return result of collision detection testing
*/
public
static
boolean
isCollidingOptimised
(
Form
A
,
Form
B
,
Circle
cA
,
Circle
cB
,
Vector2D
VA
,
Vector2D
VB
,
Vector2D
push
,
FloatA
t
)
{
return
collisionSat
(
cA
,
cB
,
VA
,
VB
,
push
,
t
)
&&
collisionSat
(
A
,
B
,
VA
,
VB
,
push
,
t
);
}
private
static
boolean
collisionSat
(
Form
A
,
Form
B
,
Vector2D
VA
,
Vector2D
VB
,
Vector2D
push
,
FloatA
t
)
{
...
...
src/main/java/org/cora/maths/collision/CollisionDetectorNoT.java
View file @
433de40e
package
org.cora.maths.collision
;
import
org.cora.maths.Circle
;
import
org.cora.maths.Form
;
import
org.cora.maths.Matrix2
;
import
org.cora.maths.Vector2D
;
...
...
@@ -9,13 +10,31 @@ import java.util.ArrayList;
public
class
CollisionDetectorNoT
{
// Collisions detection
/**
* Detect collision
* @param A test form A
* @param B test form B
* @return result of collision detection testing
*/
public
static
boolean
isColliding
(
Form
A
,
Form
B
)
{
return
collisionSatFree
(
A
,
B
);
return
collisionSat
(
A
,
B
);
}
/**
* Detect collision with circle optimisiation detection
* @param A test form A
* @param B test form B
* @param cA circle containing A
* @param cB circle containing B
* @return result of collision detection testing
*/
public
static
boolean
isCollidingOptimised
(
Form
A
,
Form
B
,
Circle
cA
,
Circle
cB
)
{
return
collisionSat
(
cA
,
cB
)
&&
collisionSat
(
A
,
B
);
}
private
static
boolean
collisionSat
Free
(
Form
A
,
Form
B
)
private
static
boolean
collisionSat
(
Form
A
,
Form
B
)
{
// Les vecteurs VA et VB sont exprimés dans le repère world
// Les points PA et PB sont exprimés dans le repères world
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment