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, 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
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
For one sheet hyperboloid I obtained an acceptable result using the gradient(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?
Thank you,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;
Would anyone be kind enough to help me calculate the normals of these objects?
Peppone