# Ray Tracing Problem

This topic is 2894 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi,
I am trying to implement a Laser beam and use ray tracing to detect the collision.

In the figure it can be seen that if the beam is in 'A' position then there is no collision and when the Laser is in
'B' position then the collision is detected and it is indicated by turning into red.

but when the laser is rotated then the same collision is not working as in the case of 'C'

For ray I am using t = startPoint + t * direction; equation

The problem I am seeing is that the calculation of start point position
THe start point of the ray is different in the case of 'C' but after using glRotatef() when I try to fetch the start point value
it gives the position same as in the case of 'A' and 'B'

How to find the updated position after rotation or is there any alternative way of doing it.

All suggestions are welcome

##### Share on other sites
We take this in our Engine to determine if the player is facing an interactable object or other player.
Here is a the Next-Function from our Ray-Class.

public virtual void Next(int steps) { Vector3 v = this.view; for (int i = 0; i < steps; i++) { v.X -= (float)Math.Sin(-this.Rotation.Y * Math.PI / 180.0) * stepWidth; v.Z -= (float)Math.Cos(-this.Rotation.Y * Math.PI / 180.0) * stepWidth; v.Y += (float)Math.Sin(-this.Rotation.X * Math.PI / 180.0) * stepWidth; } this.view = v; }

I already taked it too to have a simple fujnktion that lets a pong ball move and calculates the
incoming/outcoming colision angel.

Hope it helps you

• ### Game Developer Survey

We are looking for qualified game developers to participate in a 10-minute online survey. Qualified participants will be offered a \$15 incentive for your time and insights. Click here to start!

• 13
• 30
• 9
• 16
• 12