1

I am currently trying to develop a radar for discrete event simulation purposes. Suppose I have 2 objects Sensor S and Target T which are simply just points on screen. S is equipped with a Frustum based on specific parameters provided such as sensing distance, angle, ratio etc. That part I have already managed to develop. To put things into perspective, the Frustum begins from point S, and both S and T will move about randomly. The idea is for S to be able to detect T at discrete steps. Since S and T were programmed to move about linearly, discrete steps in this case refers to the time when either object changes direction in their movement.

My question now is, given the x,y,z position and velocity of both S and T at every discrete step, how am I able to predict the time of detection (i.e. intersection) between the Frustum of S and point T, if any? My code is currently only able to detect if a point is within the Frustum or not. But this is only useful if I am doing continuous time simulation. I am not sure as to how I should compute the intersection between a ray and the 6 planes that make up the Frustum while considering both the velocities of S and T. Some articles online mention that for dynamic object intersections, the general principle is to consider only one object to be moving before solving the equations for times t1 and t2 (i.e. relative entry and exit times). However, that doesn't seem to be working for me.

Please advise. Thanks!

Lohver
  • 11
  • 2

1 Answers1

1

To calculate the intersection of the frustum with a ray, I would suggest transforming all the points into the frustums space, so the frustum becomes an orthonormal axis-aligned box which you can use to quickly find the point of intersection.

So, start by finding all points relative to S, just by subtracting S from T.

T = T - S

Then, find T's expected position,

Tt+1  = T + Tv * dt - Sv * dt // Added the expected change for S and T

Note that the t+1 is meant to be subscript. Now, imagine you have a ray between T and Tt+1.

Anyway, next step, transform the points of the ray using a frustum matrix, ( a good example of how to construct one can be found here in the remarks section).

I don't know how you have your frustum defined, but remember to invert any rotations on your frustum before transforming the T and Tt+1 by the frustum matrix. If your frustum is rotating as well changing velocity, rotate Tt+1 by the expected frustum rotation.

The problem should now be in orthonormal space,(eg, the box is defined as -1 to 1 on all axies). Calculating the point of intersection of a line with an orthonormal box is pretty easy from there in.

Alternatively, you could just do a line-plane intersection with the six sides of the frustum.

[edit]

Sorry, I misread your original question.

Anyway, as for finding the time or entry an exit in the frustum, you can only approximate the entry and exit time of the T in the frustum.

Think of the time when the Target is at Tt, as being time 0, and when the Target is at Tt+1 as being time 1. Any point on the line segment which connects them can be represented by

P = Tt + Tv * t // Where t is the time, 0.0 - 1.0, and Tv is (Tt - Tt+1. 

This is the parametric equation for a line segment. So, if you can work out the point of intersection with the line and the plane, you can work backwards and find out t. Say POI is the point of intersection

POI // Point of intersection you calculated.
P = POI
P = Tt + Tv * t
t = (P - T) / t

If you are up to here you can approximate the time of intersection, by taking the change in time,(dt), and multiplying by the t value you calculated. Say the change is time is 3 seconds, t is 0.5, then 1.5 seconds after the Target is at T the intersection occurs. This is only an approximation, (as are all discrete physics simulations), which gets more and more accurate the smaller dt is. Does this answer your question?

Darcy Rayner
  • 3,385
  • 1
  • 23
  • 15
  • I am currently doing simple line-plane intersection tests with the six sides of the frustum, thereafter checking its legality by checking if it's within the frustum volume. Is it sufficient to "consider only one object to be moving", as mentioned above, by simply performing the transformations: Tpos = Tpos - Spos; Tvelocity = Tvelocity - Svelocity;? The new Tpos and Tvelocity will be used to form the parametric straight line equation. (Note: this does not work :() – Lohver Sep 01 '11 at 07:28
  • I have a couple of questions regarding your first solution: (1) What does T's expected pos mean?, (2) What is dt? I am assuming Sv and Tv are Sensor and Target velocities, (3) In the link it says coordinate of left-vertical clipping plane. Where is this point?, (4) I will eventually solve the intersection between the ray and the six planes that make up the frustum? (ray being the line between and T and Tt+1) - Thanks! – Lohver Sep 01 '11 at 07:48
  • You should consider the sensor as the origin. Can you describe how it fails or show some code, because it sounds logical to me. – Darcy Rayner Sep 01 '11 at 07:49
  • After transforming T's pos and velocity, an intersection occurs with the planes of the frustum but they are not "legal". Not legal here means it is not part of the frustum volume but simply an intersection with the plane portions outside of the frustum. As such, my code will not return any entry and exit times. If you're saying that the transformation "method" is logical, then I would assume something else is causing the problem? – Lohver Sep 01 '11 at 07:56
  • I defined my frustum by following the tutorial at http://www.lighthouse3d.com/tutorials/view-frustum-culling/view-frustums-shape/. If you go on to the next page, you will realise that they require the vector d (to indicate the direction of the frustum), up and right. My simulation is a top view with z-axis as the height, y-axis as forward and x-axis for movements between left and right. As such, d=(0,1,0), up=(0,0,1) and right=(1,0,0). Would this cause any problem? – Lohver Sep 01 '11 at 08:09
  • I doubt it, but if you have your frustum defined as a matrix, multiply Tt and Tt+1 by that matrix. Think of space getting bent, so the frustum is flattened out into a axis-aligned cube : http://home.earthlink.net/~zakariya/files/FrustumTransform.png , because the cube is axis aligned, you can do an easy line intersection test with it. I can explain this intersection test more if you'd like. – Darcy Rayner Sep 01 '11 at 09:43