How Does a Java Program Determine Collision Points Between Rotating Polygons?

Click For Summary
SUMMARY

This discussion focuses on developing a Java program to determine collision points between two rotating polygons. The program calculates the first contact points and angles using specific mathematical formulas. Key formulas include p = a + λd for point determination and λ = (-w^Td ± √((w^Td)² - d^Td(w^Tw - r²))) / d^Td for calculating λ. The angle of collision is derived from the cosine formula involving the distances from the pivot point to the contact points.

PREREQUISITES
  • Understanding of Java programming language
  • Familiarity with vector mathematics and geometric transformations
  • Knowledge of quadratic equations and their applications
  • Basic concepts of collision detection in computer graphics
NEXT STEPS
  • Study Java's mathematical libraries for implementing vector operations
  • Research collision detection algorithms in 2D graphics
  • Learn about geometric transformations, specifically rotation matrices
  • Explore advanced topics in computational geometry related to polygon intersection
USEFUL FOR

This discussion is beneficial for software developers, particularly those working in game development or computer graphics, as well as mathematicians interested in practical applications of geometry and collision detection algorithms.

needhelp83
Messages
193
Reaction score
0
Okay, I am struggling severely and need some guidance by anyone who understands what's going on with this. I have to write a Java program that will take two different polygons with an angle and a pivot point. The program will determine whether the second polygon hits
the first polygon as it (the second polygon) turns through the angle about the pivot point, and if it does, at exactly what angle and points on each polygon first contact happens.

The formulas I have been given to determine this is as follows:

The overall process to find point “p” is to find p= a+ λd where λ ϵ [0,1]
To find λ use the following formula, which is basically the quadratic formula modified:

λ=\frac{-w^Td \pm \sqrt{(w^Td)^2-d^Td(w^Tw-r^2)}}{d^Td}

Once you find λ, plug back into formula p= a+ λd




To find the angle in which it collides you use this:

\frac{(p-c)^T(q-c)}{||p-c||||q-c||}=cos\theta
Where the ∥p-c∥∥q-c∥ are the distances of p - c multiplied by the distance of q – c and
P – the corner point that’s rotating
Q – the contact point calculated before
C – the pivot point
 
Physics news on Phys.org
Have you been given definitions for w, d, r, and a? I'd favor a guess that a is the pivot point, but I'm not sure about the others.

Also, your solution for \lambda is the solution to the equation \|\textbf{w} + \lamda \textbf{d}\|=r.
 

Similar threads

  • · Replies 10 ·
Replies
10
Views
3K
Replies
4
Views
2K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 3 ·
Replies
3
Views
2K
Replies
5
Views
4K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 6 ·
Replies
6
Views
4K
Replies
1
Views
2K
  • · Replies 14 ·
Replies
14
Views
2K
  • · Replies 6 ·
Replies
6
Views
8K