Skip to main content
additional diagram
Source Link
Jon
  • 3.7k
  • 1
  • 14
  • 23

Two dot products, using the vector between their centers, tells you which corner is closest.
A positive "Forward" dot indicates a front corner; negative is rear.
A positive "Right" dot indicates a right corner; negative is left.
If the distance between the selected corner and the friendly is less than Range, it is in-range.

Nearest-corner test:

enter image description here

This will detect collisions that aren't caught by the nearest-corner-test:
(Diagramming purple was a mistake since it would have already passed the nearest-corner-test. The calculation will work for all cases, including perpendicular, as shown in white.
For the perpendicular, (Width / 1.0) * 1.0 == Width.)

Re-use the dots from the nearest-corner-test to find the nearest "cardinal" enemy direction (the larger of the two). Calculate the hypotenuse length and, if (DistanceBetweenCenters - HYP) <= Radius, the enemy is within range.

enter image description here

Edited to include theory and attempted to make better use of color:

enter image description here

Two dot products, using the vector between their centers, tells you which corner is closest.
A positive "Forward" dot indicates a front corner; negative is rear.
A positive "Right" dot indicates a right corner; negative is left.
If the distance between the selected corner and the friendly is less than Range, it is in-range.

Nearest-corner test:

enter image description here

This will detect collisions that aren't caught by the nearest-corner-test:
(Diagramming purple was a mistake since it would have already passed the nearest-corner-test. The calculation will work for all cases, including perpendicular, as shown in white.
For the perpendicular, (Width / 1.0) * 1.0 == Width.)

Re-use the dots from the nearest-corner-test to find the nearest "cardinal" enemy direction (the larger of the two). Calculate the hypotenuse length and, if (DistanceBetweenCenters - HYP) <= Radius, the enemy is within range.

enter image description here

Two dot products, using the vector between their centers, tells you which corner is closest.
A positive "Forward" dot indicates a front corner; negative is rear.
A positive "Right" dot indicates a right corner; negative is left.
If the distance between the selected corner and the friendly is less than Range, it is in-range.

Nearest-corner test:

enter image description here

This will detect collisions that aren't caught by the nearest-corner-test:
(Diagramming purple was a mistake since it would have already passed the nearest-corner-test. The calculation will work for all cases, including perpendicular, as shown in white.
For the perpendicular, (Width / 1.0) * 1.0 == Width.)

Re-use the dots from the nearest-corner-test to find the nearest "cardinal" enemy direction (the larger of the two). Calculate the hypotenuse length and, if (DistanceBetweenCenters - HYP) <= Radius, the enemy is within range.

enter image description here

Edited to include theory and attempted to make better use of color:

enter image description here

added 111 characters in body
Source Link
Jon
  • 3.7k
  • 1
  • 14
  • 23

Two dot products, using the vector between their centers, tells you which corner is closest.
A positive "Forward" dot indicates a front corner; negative is rear.
A positive "Right" dot indicates a right corner; negative is left.
If the distance between the selected corner and the friendly is less than Range, it is in-range.

Nearest-corner test:

enter image description here

This will detect collisions that aren't caught by the nearest-corner-test:
(Diagramming purple was a mistake since it would have already passed the nearest-corner-test. The calculation will work for all cases, including perpendicular, as shown in white.
For the perpendicular, (Width / 1.0) * 1.0 == Width.)

Re-use the dots from the nearest-corner-test to find the nearest "cardinal" enemy direction (the larger of the two). Calculate the hypotenuse length and, if (DistanceBetweenCenters - HYP) <= Radius, the enemy is within range.

enter image description here

Two dot products, using the vector between their centers, tells you which corner is closest.
A positive "Forward" dot indicates a front corner; negative is rear.
A positive "Right" dot indicates a right corner; negative is left.
If the distance between the selected corner and the friendly is less than Range, it is in-range.

Nearest-corner test:

enter image description here

This will detect collisions that aren't caught by the nearest-corner-test:
(Diagramming purple was a mistake since it would have already passed the nearest-corner-test. The calculation will work for all cases, including perpendicular, as shown in white.
For the perpendicular, (Width / 1.0) * 1.0 == Width.)

Re-use the dots from the nearest-corner-test to find the nearest "cardinal" enemy direction (the larger of the two).

enter image description here

Two dot products, using the vector between their centers, tells you which corner is closest.
A positive "Forward" dot indicates a front corner; negative is rear.
A positive "Right" dot indicates a right corner; negative is left.
If the distance between the selected corner and the friendly is less than Range, it is in-range.

Nearest-corner test:

enter image description here

This will detect collisions that aren't caught by the nearest-corner-test:
(Diagramming purple was a mistake since it would have already passed the nearest-corner-test. The calculation will work for all cases, including perpendicular, as shown in white.
For the perpendicular, (Width / 1.0) * 1.0 == Width.)

Re-use the dots from the nearest-corner-test to find the nearest "cardinal" enemy direction (the larger of the two). Calculate the hypotenuse length and, if (DistanceBetweenCenters - HYP) <= Radius, the enemy is within range.

enter image description here

added 351 characters in body
Source Link
Jon
  • 3.7k
  • 1
  • 14
  • 23

Two dot products, using the vector between their centers, tells you which corner is closest.

A
A positive "Forward" dot indicates a front corner; negative is rear.
A positive "Right" dot indicates a right corner; negative is left.

If
If the distance between the selected corner and the friendly is less than Range, it is in-range.

Nearest-corner test:

enter image description here

This will detect collisions that aren't caught by the nearest-corner-test:This will detect collisions that aren't caught by the nearest-corner-test:
(Diagramming purple was a mistake since it would have already passed the nearest-corner-test, but the. The calculation will work for all cases, including the perpendicular case, as shown in white.
For the perpendicular, (Width / 1.0) * 1.0 == Width.)

Re-use the dots from the nearest-corner-test to find the nearest "cardinal" enemy direction (the larger of the two).

enter image description here

Two dot products, using the vector between their centers, tells you which corner is closest.

A positive "Forward" dot indicates a front corner; negative is rear.
A positive "Right" dot indicates a right corner; negative is left.

If the distance between the selected corner and the friendly is less than Range, it is in-range.

enter image description here

This will detect collisions that aren't caught by the nearest-corner-test:
(Diagramming purple was a mistake since it would have already passed the nearest-corner-test, but the calculation will work for all cases, including the perpendicular case, shown in white.

enter image description here

Two dot products, using the vector between their centers, tells you which corner is closest.
A positive "Forward" dot indicates a front corner; negative is rear.
A positive "Right" dot indicates a right corner; negative is left.
If the distance between the selected corner and the friendly is less than Range, it is in-range.

Nearest-corner test:

enter image description here

This will detect collisions that aren't caught by the nearest-corner-test:
(Diagramming purple was a mistake since it would have already passed the nearest-corner-test. The calculation will work for all cases, including perpendicular, as shown in white.
For the perpendicular, (Width / 1.0) * 1.0 == Width.)

Re-use the dots from the nearest-corner-test to find the nearest "cardinal" enemy direction (the larger of the two).

enter image description here

added 351 characters in body
Source Link
Jon
  • 3.7k
  • 1
  • 14
  • 23
Loading
added 2 characters in body
Source Link
Jon
  • 3.7k
  • 1
  • 14
  • 23
Loading
edited body
Source Link
Jon
  • 3.7k
  • 1
  • 14
  • 23
Loading
edited body
Source Link
Jon
  • 3.7k
  • 1
  • 14
  • 23
Loading
added 22 characters in body
Source Link
Jon
  • 3.7k
  • 1
  • 14
  • 23
Loading
Source Link
Jon
  • 3.7k
  • 1
  • 14
  • 23
Loading