I didnt think of that, but i suppose it would be along the now tilted wall? So the angle would always be measured on the surface of whatever object the disc falls on.
In that case, what you might want to consider doing is a method that's more general: using dot products (could use cross products too, but dots involve slightly less computation).
Procedure:
1. Find the two vectors along the two lines that form the angle in which you're interested.
2. Compute the dot product "both ways"; that is, plug everything into the formula
where is the angle between the two vectors.
3. Solve for as per the following:
Your step 1 here, in turn, will be composed of the steps of finding the equations for the planes whose intersection forms the lines, and then finding a vector that points in the direction of the line. Example:
Take the planes
and
The first plane is the disc, you can see, and the second plane is just an arbitrary plane I chose. Now treat both these equations as simultaneous equations. You should be able to get it down to one arbitrary parameter that basically enables you to traverse the line. Solution:
The equations these computations represent are as follows:
and hence we see immediately that Plugging this back in, we see that or Setting as our parameter, we can represent the equation of the line as
Hence, a vector parallel to the line generated by the intersection of these two planes is given by
Perform this same procedure with the intersection of the tilted wall and the ground, and you'll get another vector. This constitutes step 1.
Does all this make sense?
It comes from the general equation of a line in 3D. You have
where is a vector in the direction of the line, and is a point on the line. It's essentially the same thing as your . In this case, the since the line goes through the origin (plug in , and you'll see that).
Make sense?
Yeah, you could sort of combine steps 2 and 3 by just saying that you plug everything into the formula you just quoted. This will give you alpha. I should point out that alpha will be the acute angle between the two lines, because that's what the arccosine function gives you. Most of the time, that's probably adequate. But if you need the obtuse angle between two lines, you'll have to exploit the symmetries of the cosine function to find it.
Ok, i think i have my head around most of it now, but now i find im falling at the first hurdle! Calculating the surface normals. I'm testing for other surfaces.
I had been using these for a three dimensional rotation.
Rotation matrix - Wikipedia, the free encyclopedia
To clarify, what i had been doing was, as it is a 3D rotation, substituting 45^ (or whatever angles I choose for a test) into two rotation matrices, depending on what two axis i am rotating around.
I then multiply Rx x Ry x Rz, as it mentions further down for matrix multiplication.
For the 45^ multiplication, I got
Code:0.7071 -0.7071 0 0.5000 0.5000 -0.7071 0.5000 0.5000 0.7071
But now i think i should be doing it this way
Step 1: I take the three rotation matrices, and rotate them around different axes, by a set number of degrees. This means substituting 45^ for theta in each. I then multiply Rx by Ry by Rz. This gives me a 3 x 3 matrix, like i have above.
Step 2: I then take the surface normals of the plane before I rotated it, 1,0,0 for vertical, or 0,0,1 for horizontal, and multiply this 3x1 matrix by a 3x3, giving me a 3x1 matrix.
Im not sure if im right though...
If you have the equation of a plane, computing surface normals involves the following steps:
1. Compute the coordinates of three points in the plane that are NOT collinear. Call them , , . You can do this by simply plugging in whatever values you want for x and y, and then solving for the z's.
2. Form two linearly independent vectors as follows:
3. The cross product is a vector normal to the plane.
But, taking a step back here, refresh my memory a little: do you already have the equations for all the planes that you need? Or are taking a known plane and rotating it? Or how do you propose to get the equations for the plane?