Collision Detection and Distance

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/20

encourage image

There's no tags or description

Looks like no tags are added yet.

21 Terms

1
New cards

What is collision detection?

The process of checking whether two objects touch or overlap.

2
New cards

What is distance?

The amount of space between two points or objects.

3
New cards

What do x and y represent in Canvas?

The horizontal and vertical coordinates of a position.

4
New cards

What do x1 and y1 represent?

The first object's centre coordinates.

5
New cards

What do x2 and y2 represent?

The second object's centre coordinates.

6
New cards

What is the formula for distance between two points?

d = √((x2 − x1)² + (y2 − y1)²).

7
New cards

What is the order for calculating distance using the formula?

Subtract the coordinates, square the differences, add them, and calculate the square root.

8
New cards

What is a radius?

The distance from the centre of a circle to its edge.

9
New cards

What is the circle collision condition?

d ≤ r1 + r2.

10
New cards

What does d represent in the circle collision condition?

The distance between the centres of the two circles.

11
New cards

What do r1 and r2 represent?

The radii of the first and second circles.

12
New cards

When do two circles collide or touch?

When the distance between their centres is less than or equal to the sum of their radii.

13
New cards

When do two circles not collide?

When the distance between their centres is greater than the sum of their radii.

14
New cards

Two circles have radii of 3 and 4 pixels, and their centres are 5 pixels apart. Is there a collision?

Yes. 5 ≤ 3 + 4, so the circles overlap.

15
New cards

Two circles have radii of 2 and 3 pixels, and their centres are 8 pixels apart. Is there a collision?

No. 8 > 2 + 3, so the circles do not touch.

16
New cards

What does Math.sqrt() do in JavaScript?

It calculates the square root of a number.

17
New cards

What do dx and dy commonly represent in collision-detection code?

The horizontal and vertical differences between two objects' centre coordinates.

18
New cards

What does the <= operator mean?

Less than or equal to.

19
New cards

What does an if statement do?

It runs a block of code when its condition is true.

20
New cards

Why are the radii added together when checking circle collisions?

The sum gives the maximum centre distance at which two circles can touch.

21
New cards

Which collision-detection method is described by comparing centre distance with the sum of radii?

Circle-based collision detection.