How to bounce a point from a line?

I am working on writing a pong game, and I ran into a problem.

I am trying to figure out how to bounce a point from a line.

The best way I can do this is

  • Calculate the current and future position of the ball.
    • Line segment: {Ball.location, Ball.location + Ball.direction} (Ball.location and Ball.direction use a custom vector / coordinate class)
  • Calculate if the generated line segment intersects with any of the walls or blades.
    • ??? I don’t know how to do this (ask in a separate question)
  • At the first intersection found
    • Kick the ball off the line
      • Create a triangle formed with
        • a = Current step position
        • b = The point of intersection of the line.
        • c = The closest point to the current position of the ball on the line.
      • Find the angle at which the ball hits the line
        • angle = cos ( (b, c)/ (a, b))
        • (90 - ) * 2
        • , ,
    • .

- ?

+3
6

, , , . , .

+5

, Pong , , . dx, dy. , dy. , dx.

+2

, .
, PAST . , , .

, , , , :

Public Function TranslatePoint(ByVal tStartPoint As Point, _
ByVal tAngle as Decimal, ByVal tDistance As Decimal) As Point
+1

:

1) , pong x = a x = b

2) (x0, y0) Ax + By = C

3) (x1, y1) ,        

4) , ,        (x0, y1 + y0) . ( y1-y0         , , y1 + y0 .)

5), 2 , ( ).

0

, N Tutorials, ( ), "N".

, , , - .

0

Bouncing is a physics issue, not a graphic domain. Therefore, OpenGL does not offer any real support. If you look at the hardware, you will notice that there were separate physical cards similar to video cards, although the most recent trends include their integration.

0
source

Source: https://habr.com/ru/post/1708303/


All Articles