Quote:Original post by Xrystal
Can someone confirm I am understanding this correctly ?
You have a lot of question so hopefully I answer them all.
Quote:Cross Product of 2 vectors (A and B) result in a 3rd vector that is perpendicular to the two (ie splitting the angle in two or as I initially thought a line making a right angle)?
In R^3 space it will. Also, remember these two important exceptions to the rule. It will result in a zero vector if one of the vectors has zero length, or both vectors are colinear.
Quote:Dot Product of the 2 vectors result in the length of the aforementioned vector?
Ax * Bx + Ay * By + Az * Bz
Sometimes but not always. It's the projected length of one vector on to another. If vector B is normalized and vector A is facing the same direction then you will get the length of vector A and that is really the only case.
Though, this little trick is used a lot to get the magnitude squared of a vector. If you dot(a,a) then you'll get ||A||^2. (The two surounding || || represent the symbol for magnitude.) This is a useful trick because when your comparing distance you can compare it squared or non-squared and the comparison works the same.
Quote:Normalizing returns the direction vector and not the length ?
t = Sqrt(x*x + y*y + z*z);
x /= t;
y /= t;
z /= t;
Not quite correct. Normalizing a vector returns the same vector, except with a unit length of one. Also, be careful of the case of zero vectors, you'll get an exception if you try to divide x,y,z by t if t = 0.
Quote:I understand this is for a single vector with each point multiplying itself or are these the 2 initial vectors being multiplied against each other ?
I don't understand what you're asking.
Quote:It says that sqrt(Cx*Cx + Cy*Cy + Cz*Cz) is the distance from the ray to the sphere center (target to test). I assume the Cx,Cy,Cz values are the co-ords for the center of the sphere as the site doesn't say this explicitly. Looking at the formula above it looks like this is the first stage of normalising but not completely or are they just missing that part assuming we know to include the rest of the normalise process.
That formula is for finding the distance from the origin to the center of the shere. That is the distance formula. It's derived from the pythagorus theorum of a^2 + b^2 = hypotonus^2. It also works in R^3 space. If you write that formula out using the sphere's center as the x and y and solve for the hypotonus then you'll get the same formula they have above.
Quote:It then says to multiply the Ray Original End Point (unit length) to that resulting value to retrieve the new end point. However I am not clear on the original end point. Is that the RayDir that is gained from normalize the Start point.
| Vx | = Dx * sqrt(Cx*Cx + Cy*Cy + Cz*Cz)
| Vy | = Dy * sqrt(Cx*Cx + Cy*Cy + Cz*Cz)
| Vz | = Dz * sqrt(Cx*Cx + Cy*Cy + Cz*Cz)
where Dx,Dy,Dz is the original Ray End Point.
If you look at the picture and at the red line. Imagine creating a vector from the origin to the center of the sphere. Then sweeping it in a circle, the end point of that vector would draw that red line. What they are doing is just making our ray(which is normally unit length) and stretching it so it has the same magnitude as the distance of the center of the sphere. We want to make sure the ray's end point falls on that red line.
To use numbers. Imagine the ray pointed straight up Ray<0,1>. If the sphere was 5 units away, then we would want the ray's end point to fall on that red line. We would have to multiply the Ray<0,1>*5 = Ray<0,5>.
Quote:Step 6 : If not intersected return nearest point, again I cannot see how a non Sphere would work here.
*** Source Snippet Removed ***
Good observation. This type of intersection test only works for spheres.