# Thread: Calculate angels of a point object

1. Senior Member
Join Date
Aug 2011
Posts
251
Rep Power
6

## Calculate angels of a point object

Hey guys,
I want to calculate the x & y of a point object after it hits a frame.
Theoretical I think that the angle of the point need to be multiplied in -1 after it hits a frame.
Practical I do not know how to implement it,

2. ## Re: Calculate angels of a point object

want to calculate the x & y of a point object after it hits a frame.
Are you drawing a shape that hits another shape as it is moving across your window?
You need to consider where the two shapes are located in 2 dimensions and see when the boundary of one shape touches the boundary of the other shape. Drawing this on paper will help you to see where the boundaries are and where the boundary of one touches the boundary of the other.
the angle of the point need to be multiplied in -1 after it hits a frame
Not sure what you mean here. A point doesn't have an angle. Do you mean the angle between the path of the point and the boundary of the shape that the moving point is coming in contact with? Are you trying to have the point bounce off the boundary and move in a new direction?

Do you have some code you can post to show your problem?

3. ## Re: Calculate angels of a point object

If a point travels with a speed (dx, dy) toggle the sign of dx if the point hits a vertical wall; toggle the sign of dy if it hits a horizontal wall.

kind regards,

Jos
Last edited by JosAH; 11-16-2011 at 09:19 AM. Reason: fixed a stupid typo ...

4. Senior Member
Join Date
Aug 2011
Posts
251
Rep Power
6

## Re: Calculate angels of a point object

Originally Posted by Norm
Are you drawing a shape that hits another shape as it is moving across your window?
No, I'm drawing a shape that hits the window frames.

Originally Posted by Norm
Not sure what you mean here. A point doesn't have an angle.
I know! I just trying to find a way to calculate the new values after the object confluenction.

Originally Posted by Norm
Are you trying to have the point bounce off the boundary and move in a new direction?

Do you have some code you can post to show your problem?

Truthly, no.
I just got a simple point on my screen.
Looks like I got 2 problems now:

1)I want the point to move randomly on the screen. Moving it with 90 degrees it's easy .. just x++ or y++ but I want the point to move as the ball move on the picture I attached.
2)When it hits the window frame, what the values will be then?

Originally Posted by JosAH
If a point travels with a speed (dx, dy) toggle the sign of dx if the point hits a vertical wall; toggle the sign of dy if it hits a horizontal wall.
Yea I know that but what happens if the ball is not re painting by x++ or y++, if it's x+=3, y+=10

Thanks guys.

edit: JoshAH, I think your answer is working for all the cases.
I will test it now.

5. ## Re: Calculate angels of a point object

I want the point to move as the ball move on the picture I attached.
If you change the x and/or y values over time, the location will change.

When it hits the window frame, what the values will be then?
Print out the values of x and y as the ball moves to see their values.
Do you know the size of the window frame?

6. ## Re: Calculate angels of a point object

Originally Posted by tnrh1
edit: JoshAH, I think your answer is working for all the cases.
I know, that's why I posted it ;-)

kind regarrds,

Jos

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•