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

In summary, the conversation discusses the task of writing a Java program to determine the collision between two polygons as one rotates around a pivot point. The formulas provided to solve this problem involve finding a specific point using a quadratic formula, as well as calculating the angle of collision using a trigonometric formula. Questions are asked about the given definitions of variables and the purpose of certain values in the equations.
  • #1
needhelp83
199
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:

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

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




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

[tex]\frac{(p-c)^T(q-c)}{||p-c||||q-c||}=cos\theta[/tex]
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
  • #2
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 [tex]\lambda[/tex] is the solution to the equation [tex]\|\textbf{w} + \lamda \textbf{d}\|=r[/tex].
 

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

1. What is a rotating polygon on a graph?

A rotating polygon on a graph is a shape that is drawn on a coordinate plane and then rotated about a point. The rotation of the shape can be clockwise or counterclockwise.

2. How do you rotate a polygon on a graph?

To rotate a polygon on a graph, you can use the rotation formula: x' = x*cos(angle) - y*sin(angle) and y' = x*sin(angle) + y*cos(angle). This formula will give you the new coordinates of each point after the rotation.

3. What is the difference between rotating a polygon and translating it?

Rotating a polygon involves rotating the shape around a fixed point, while translating a polygon involves moving the shape horizontally and vertically without changing its orientation.

4. What is the purpose of rotating polygons on a graph?

Rotating polygons on a graph can be used in various applications, such as computer graphics, animation, and engineering. It allows us to visualize and manipulate shapes in different orientations and can help with problem-solving and design.

5. Is there a maximum number of sides a rotating polygon can have?

No, there is no maximum number of sides a rotating polygon can have. As long as the shape can be drawn on a coordinate plane, it can be rotated around a point.

Similar threads

  • Calculus and Beyond Homework Help
Replies
10
Views
2K
Replies
5
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
322
  • Calculus and Beyond Homework Help
Replies
4
Views
1K
  • Calculus and Beyond Homework Help
Replies
4
Views
1K
  • Linear and Abstract Algebra
Replies
1
Views
962
  • Differential Geometry
Replies
1
Views
1K
  • Special and General Relativity
Replies
11
Views
294
Replies
14
Views
1K
  • Introductory Physics Homework Help
Replies
6
Views
3K
Back
Top