# Calculate angels of a point object

• 11-15-2011, 04:42 PM
tnrh1
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,

• 11-15-2011, 05:00 PM
Norm
Re: Calculate angels of a point object
Quote:

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.
Quote:

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?
• 11-15-2011, 05:02 PM
JosAH
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
• 11-17-2011, 12:17 AM
tnrh1
Re: Calculate angels of a point object
Quote:

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.

Quote:

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.

Quote:

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

:(y):

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?

Quote:

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.
• 11-17-2011, 12:26 AM
Norm
Re: Calculate angels of a point object
Quote:

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.

Quote:

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?
• 11-17-2011, 09:25 AM
JosAH
Re: Calculate angels of a point object
Quote:

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