Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calculate the horizon of a curved face? - Not extrema

Tags:

I need to find the 2 points of the visual horizon, of a curved face.

I have:

  • XYZ of the 4 corner points
  • XYZ of the 2 curved edge bezier points

And I need to calculate either:

  • XY of the 2 horizon points
  • XYZ of the 2 horizon points

Note: I got a solution the last time I asked this question, but it only found the extrema of the curves, not the horizon points, which changes based on the position and rotation of both curves in respect to each other.

like image 295
Robin Rodricks Avatar asked Feb 22 '09 11:02

Robin Rodricks


2 Answers

You don't say how your surface is defined, only that it is bounded by two quadratic Bézier curves. There are lots of ways to build such a surface, and each way of building it would have a different horizon. So this answer is going to be guesswork.

The horizon consists of those points on the surface where the vector from the camera to the point is tangent to the surface, as shown here:

Tangent to Bézier curve

A quadratic Bézier curve has parametric equation

B(t) = (1 − t)2 P0 + 2(1 − t)t P1 + t2 P2

differentiating that with respect to t gives us the tangent to the curve:

B′(t) = 2(t − 1) P0 + 2(1 − 2t) P1 + 2t P2

and this is parallel with the vector from the camera (at the origin) to the curve if

B(t) × B′(t) = 0

Solve this for t and you'll have the point on the curve at the horizon. How you can extend this to the horizon for the whole surface depends on how your surface is constructed. (Maybe you can just find the horizon points for the curves at each end of the surface and join them with a straight line?)

like image 164
Gareth Rees Avatar answered Oct 04 '22 20:10

Gareth Rees


Does it work to first rotate the curves so that the connection between the corner points is horizontal and then calculating the extrema?

To test it visually, you can rotate your example image by about 150 degree:

Rotated image http://www.freeimagehosting.net/uploads/ad502509e9.png

Note the extrema of this curve isn't exactly where you want it, but this could be caused by several factors, for example the way you marked the horizon points doesn't seem to be that exact.

like image 21
schnaader Avatar answered Oct 04 '22 22:10

schnaader