### Post by peppone on Jan 17, 2020 0:32:24 GMT

Hi,

First of all, my congratulations to the author of the book, topics are developed clearly (impossible to find the same quality in ray-tracing guides available on the internet).

After implementing, sphere, cone and cylinder, I had fun calculating the coefficients of other four quadratic figures:

So,

The cylinder normal vector is less intuitive because I don't understand why Y is equal to sqrt(x * x + z * z) since all formulas that I can find on the internet for the cones aligned on the y axis are different.

Many articles suggest to take the gradient of F(x,y,z) to calculate the equation of the normal but for

Unfortunately, I find the same difficulty to calculate the normal vector with the new figures I implemented.

Here are the coefficient formulas of hyperboloids if you are interested. (r = ray)

For one sheet hyperboloid I obtained an acceptable result using the gradient

Would anyone be kind enough to help me calculate the normals of these objects?

Thank you,

Peppone

First of all, my congratulations to the author of the book, topics are developed clearly (impossible to find the same quality in ray-tracing guides available on the internet).

After implementing, sphere, cone and cylinder, I had fun calculating the coefficients of other four quadratic figures:

- One sheet hyperboloid
_{f=x^2-y^2+z^2 - 1} - Two sheets hyperboloid
_{f=-x^2+y^2-z^2 - 1} - Paraboloid elliptic
_{f=-x^2+z^2-y} - Paraboloid hyperbolic
_{f=-x^2-z^2-y}

So,

__in object coordinate__, it is clear to me that the normal of a sphere is 'the intersection point' and that the normal of a cylinder is 'the intersection point without the Y'.The cylinder normal vector is less intuitive because I don't understand why Y is equal to sqrt(x * x + z * z) since all formulas that I can find on the internet for the cones aligned on the y axis are different.

Many articles suggest to take the gradient of F(x,y,z) to calculate the equation of the normal but for

_{f=x2+y2−z2}, I obtain_{(2x,2y,−2z)}which is different of_{(x, sqrt(x*x+y*y), z)}.Unfortunately, I find the same difficulty to calculate the normal vector with the new figures I implemented.

Here are the coefficient formulas of hyperboloids if you are interested. (r = ray)

**hyperboloid_1Sheet**

a = r.dir.x * r.dir.x - r.dir.y * r.dir.y + r.dir.z * r.dir.z;

b = 2 * (r.ori.x * r.dir.x - r.ori.y * r.dir.y + r.ori.z * r.dir.z);

c = r.ori.x * r.ori.x - r.ori.y * r.ori.y + r.ori.z * r.ori.z - 1;

b = 2 * (r.ori.x * r.dir.x - r.ori.y * r.dir.y + r.ori.z * r.dir.z);

c = r.ori.x * r.ori.x - r.ori.y * r.ori.y + r.ori.z * r.ori.z - 1;

**hyperboloid_2Sheet**

a = - r.dir.x * r.dir.x + r.dir.y * r.dir.y - r.dir.z * r.dir.z;

b = 2 * (- r.ori.x * r.dir.x + r.ori.y * r.dir.y - r.ori.z * r.dir.z);

c = - r.ori.x * r.ori.x + r.ori.y * r.ori.y - r.ori.z * r.ori.z - 1;

b = 2 * (- r.ori.x * r.dir.x + r.ori.y * r.dir.y - r.ori.z * r.dir.z);

c = - r.ori.x * r.ori.x + r.ori.y * r.ori.y - r.ori.z * r.ori.z - 1;

_{(2x,−2y,2z)}of

_{f=x^2-y^2+z^2 - 1}as normal vector but I'm not sure it's correct.

Would anyone be kind enough to help me calculate the normals of these objects?

_{}

Peppone