Skip to main content
added 33 characters in body
Source Link
Jon
  • 3.7k
  • 1
  • 13
  • 23

Once you calculate the new up, you'll want the lerp from old to new to take a few seconds. Additionally, if CameraToObject and PlanetToObject are coincident, a single plane cannot be defined. If the object is already selected, your vertical constraint will prevent CameraToObject and PlanetToObject from becoming coincident, however, if the two are already coincident when you click the object, or are made coincident by clicking the object, the algorithm will not work. So, if you go to calculate and detect that they are coincident, bump one a tiny bit; this will find an up vector, which allows the camera to begin lerping, which allows the vertical constraint to work.

The cross-product of the normalized PlanetToObject and CameraToObject directions is perpendicular to both vectors and is, by definition, the normal of a plane that contains both. The cross product of the plane's normal (perpendicular to the plane) and CameraToObject (a vector in the plane) is a second vector in the same plane, perpendicular to the first; the net-result is a rotation of CameraToObject 90 degrees around the face normal.

Note: I may or may not have reversed the order of the cross-products, but you only need to worry about it at the very end; the yellow vector should point to the "right of the camera"; invert it if it doesn't.

This was one of the hardest screenshots I've tried to diagram over; I had given up on making it look right but will post it anyway, since I think you'll still get it.

enter image description here

Regarding quats:

Consider the specific wording of your question. "I want to rotate the image counter-clockwise". That's also saying that you want to rotate the camera clock-wise around CameraToObject. In that case, CameraToObject is the Quaternion's vector component, and "90 degrees" is the scalar component. Quaternions twist inputs around their vector component by the angle stored in their scalar component.

A few quaternions youYou didn't know youyou've already knew aboutbeen using quaternions for matrix math? With unit-axis vector components, the quaternion equation reduces to the appropriate axis-rotation matrices:

enter image description here

Once you calculate the new up, you'll want the lerp from old to new to take a few seconds. Additionally, if CameraToObject and PlanetToObject are coincident, a single plane cannot be defined. If the object is already selected, your vertical constraint will prevent CameraToObject and PlanetToObject from becoming coincident, however, if the two are already coincident when you click the object, or are made coincident by clicking the object, the algorithm will not work. So, if you go to calculate and detect that they are coincident, bump one a tiny bit; this will find an up vector, which allows the camera to begin lerping, which allows the vertical constraint to work.

The cross-product of the normalized PlanetToObject and CameraToObject directions is perpendicular to both vectors and is, by definition, the normal of a plane that contains both. The cross product of the plane's normal (perpendicular to the plane) and CameraToObject (a vector in the plane) is a second vector in the same plane, perpendicular to the first; the net-result is a rotation of CameraToObject 90 degrees around the face normal.

Note: I may or may not have reversed the order of the cross-products, but you only need to worry about it at the very end; the yellow vector should point to the "right of the camera"; invert it if it doesn't.

This was one of the hardest screenshots I've tried to diagram over; I had given up on making it look right but will post it anyway, since I think you'll still get it.

enter image description here

Regarding quats:

Consider the specific wording of your question. "I want to rotate the image counter-clockwise". That's also saying that you want to rotate the camera clock-wise around CameraToObject. In that case, CameraToObject is the Quaternion's vector component, and "90 degrees" is the scalar component. Quaternions twist inputs around their vector component by the angle stored in their scalar component.

A few quaternions you didn't know you already knew about:

enter image description here

Once you calculate the new up, you'll want the lerp from old to new to take a few seconds. Additionally, if CameraToObject and PlanetToObject are coincident, a single plane cannot be defined. If the object is already selected, your vertical constraint will prevent CameraToObject and PlanetToObject from becoming coincident, however, if the two are already coincident when you click the object, or are made coincident by clicking the object, the algorithm will not work. So, if you go to calculate and detect that they are coincident, bump one a tiny bit; this will find an up vector, which allows the camera to begin lerping, which allows the vertical constraint to work.

The cross-product of the normalized PlanetToObject and CameraToObject directions is perpendicular to both vectors and is, by definition, the normal of a plane that contains both. The cross product of the plane's normal (perpendicular to the plane) and CameraToObject (a vector in the plane) is a second vector in the same plane, perpendicular to the first; the net-result is a rotation of CameraToObject 90 degrees around the face normal.

Note: I may or may not have reversed the order of the cross-products, but you only need to worry about it at the very end; the yellow vector should point to the "right of the camera"; invert it if it doesn't.

This was one of the hardest screenshots I've tried to diagram over; I had given up on making it look right but will post it anyway, since I think you'll still get it.

enter image description here

Regarding quats:

Consider the specific wording of your question. "I want to rotate the image counter-clockwise". That's also saying that you want to rotate the camera clock-wise around CameraToObject. In that case, CameraToObject is the Quaternion's vector component, and "90 degrees" is the scalar component. Quaternions twist inputs around their vector component by the angle stored in their scalar component.

You didn't know you've already been using quaternions for matrix math? With unit-axis vector components, the quaternion equation reduces to the appropriate axis-rotation matrices:

enter image description here

added 33 characters in body
Source Link
Jon
  • 3.7k
  • 1
  • 13
  • 23

Once you calculate the new up, you'll want the lerp from old to new to take a few seconds. Additionally, if CameraToObject and PlanetToObject are coincident, a single plane cannot be defined. If the object is already selected, your vertical constraint will prevent CameraToObject and PlanetToObject from becoming coincident, however, if the two are already coincident when you click the object, or are made coincident by clicking the object, the algorithm will not work. So, if you go to calculate and detect that they are coincident, bump one a tiny bit; this will find an up vector, which allows the camera to begin lerping, which allows the vertical constraint to work.

The cross-product of the normalized PlanetToObject and CameraToObject directions is perpendicular to both vectors and is, by definition, the normal of a plane that contains both. The cross product of the plane's normal (perpendicular to the plane) and CameraToObject (a vector in the plane) is a second vector in the same plane, perpendicular to the first; the net-result is a rotation of CameraToObject 90 degrees around the face normal.

Note: I may or may not have reversed the order of the cross-products, but you only need to worry about it at the very end; the yellow vector should point to the "right of the camera"; invert it if it doesn't.

This was one of the hardest screenshots I've tried to diagram over; I had given up on making it look right but will post it anyway, since I think you'll still get it.

enter image description here

Regarding quats:

Consider the specific wording of your question. "I want to rotate the image counter-clockwise". That's also saying that you want to rotate the camera clock-wise around CameraToObject. In that case, CameraToObject is the Quaternion's vector component, and "90 degrees" is the scalar component. Quaternions twist inputs around their vector component by the angle stored in their scalar component. Visualize the earth spinning on it's axis; it only has one axis to spin on so the only question left is "How much?"

A few quaternions you didn't know you already knew about:

enter image description here

Once you calculate the new up, you'll want the lerp from old to new to take a few seconds. Additionally, if CameraToObject and PlanetToObject are coincident, a single plane cannot be defined. If the object is already selected, your vertical constraint will prevent CameraToObject and PlanetToObject from becoming coincident, however, if the two are already coincident when you click the object, or are made coincident by clicking the object, the algorithm will not work. So, if you go to calculate and detect that they are coincident, bump one a tiny bit; this will find an up vector, which allows the camera to begin lerping, which allows the vertical constraint to work.

The cross-product of the normalized PlanetToObject and CameraToObject directions is perpendicular to both vectors and is, by definition, the normal of a plane that contains both. The cross product of the plane's normal (perpendicular to the plane) and CameraToObject (a vector in the plane) is a second vector in the same plane, perpendicular to the first; the net-result is a rotation of CameraToObject 90 degrees around the face normal.

Note: I may or may not have reversed the order of the cross-products, but you only need to worry about it at the very end; the yellow vector should point to the "right of the camera"; invert it if it doesn't.

This was one of the hardest screenshots I've tried to diagram over; I had given up on making it look right but will post it anyway, since I think you'll still get it.

enter image description here

Regarding quats:

Consider the specific wording of your question. "I want to rotate the image counter-clockwise". That's also saying that you want to rotate the camera clock-wise around CameraToObject. In that case, CameraToObject is the Quaternion's vector component, and "90 degrees" is the scalar component. Quaternions twist inputs around their vector component by the angle stored in their scalar component. Visualize the earth spinning on it's axis; it only has one axis to spin on so the only question left is "How much?"

Once you calculate the new up, you'll want the lerp from old to new to take a few seconds. Additionally, if CameraToObject and PlanetToObject are coincident, a single plane cannot be defined. If the object is already selected, your vertical constraint will prevent CameraToObject and PlanetToObject from becoming coincident, however, if the two are already coincident when you click the object, or are made coincident by clicking the object, the algorithm will not work. So, if you go to calculate and detect that they are coincident, bump one a tiny bit; this will find an up vector, which allows the camera to begin lerping, which allows the vertical constraint to work.

The cross-product of the normalized PlanetToObject and CameraToObject directions is perpendicular to both vectors and is, by definition, the normal of a plane that contains both. The cross product of the plane's normal (perpendicular to the plane) and CameraToObject (a vector in the plane) is a second vector in the same plane, perpendicular to the first; the net-result is a rotation of CameraToObject 90 degrees around the face normal.

Note: I may or may not have reversed the order of the cross-products, but you only need to worry about it at the very end; the yellow vector should point to the "right of the camera"; invert it if it doesn't.

This was one of the hardest screenshots I've tried to diagram over; I had given up on making it look right but will post it anyway, since I think you'll still get it.

enter image description here

Regarding quats:

Consider the specific wording of your question. "I want to rotate the image counter-clockwise". That's also saying that you want to rotate the camera clock-wise around CameraToObject. In that case, CameraToObject is the Quaternion's vector component, and "90 degrees" is the scalar component. Quaternions twist inputs around their vector component by the angle stored in their scalar component.

A few quaternions you didn't know you already knew about:

enter image description here

added 269 characters in body
Source Link
Jon
  • 3.7k
  • 1
  • 13
  • 23

Once you calculate the new up, you'll want the lerp from old to new to take a few seconds. Additionally, if CameraToObject and PlanetToObject are coincident, a single plane cannot be defined. If the object is already selected, your vertical constraint will prevent CameraToObject and PlanetToObject from becoming coincident, however, if the two are already coincident when you click the object, or are made coincident by clicking the object, the algorithm will not work. So, if you go to calculate and detect that they are coincident, bump one a tiny bit; this will find an up vector, which allows the camera to begin lerping, which allows the vertical constraint to work.

The cross-product of the normalized PlanetToObject and CameraToObject directions is perpendicular to both vectors and is, by definition, the normal of a plane that contains both. The cross product of the plane's normal (perpendicular to the plane) and CameraToObject (a vector in the plane) is a second vector in the same plane, perpendicular to the first; the net-result is a rotation of CameraToObject 90 degrees around the face normal.

Note: I may or may not have reversed the order of the cross-products, but you only need to worry about it at the very end; the yellow vector should point to the "right of the camera"; invert it if it doesn't.

This was one of the hardest screenshots I've tried to diagram over; I had given up on making it look right but will post it anyway, since I think you'll still get it.

enter image description here

Regarding quats:

Consider the specific wording of your question. "I want to rotate the image counter-clockwise". That's also saying that you want to rotate the camera clock-wise around CameraToObject. In that case, CameraToObject is the Quaternion's vector component, and "90 degrees" is the scalar component. Quaternions twist inputs around their vector component by the angle stored in their scalar component. Visualize the earth spinning on it's axis; it only has one axis to spin on so the only question left is "How much?"

Once you calculate the new up, you'll want the lerp from old to new to take a few seconds.

The cross-product of the normalized PlanetToObject and CameraToObject directions is perpendicular to both vectors and is, by definition, the normal of a plane that contains both. The cross product of the plane's normal (perpendicular to the plane) and CameraToObject (a vector in the plane) is a second vector in the same plane, perpendicular to the first; the net-result is a rotation of CameraToObject 90 degrees around the face normal.

Note: I may or may not have reversed the order of the cross-products, but you only need to worry about it at the very end; the yellow vector should point to the "right of the camera"; invert it if it doesn't.

This was one of the hardest screenshots I've tried to diagram over; I had given up on making it look right but will post it anyway, since I think you'll still get it.

enter image description here

Regarding quats:

Consider the specific wording of your question. "I want to rotate the image counter-clockwise". That's also saying that you want to rotate the camera clock-wise around CameraToObject. In that case, CameraToObject is the Quaternion's vector component, and "90 degrees" is the scalar component. Quaternions twist inputs around their vector component by the angle stored in their scalar component. Visualize the earth spinning on it's axis; it only has one axis to spin on so the only question left is "How much?"

Once you calculate the new up, you'll want the lerp from old to new to take a few seconds. Additionally, if CameraToObject and PlanetToObject are coincident, a single plane cannot be defined. If the object is already selected, your vertical constraint will prevent CameraToObject and PlanetToObject from becoming coincident, however, if the two are already coincident when you click the object, or are made coincident by clicking the object, the algorithm will not work. So, if you go to calculate and detect that they are coincident, bump one a tiny bit; this will find an up vector, which allows the camera to begin lerping, which allows the vertical constraint to work.

The cross-product of the normalized PlanetToObject and CameraToObject directions is perpendicular to both vectors and is, by definition, the normal of a plane that contains both. The cross product of the plane's normal (perpendicular to the plane) and CameraToObject (a vector in the plane) is a second vector in the same plane, perpendicular to the first; the net-result is a rotation of CameraToObject 90 degrees around the face normal.

Note: I may or may not have reversed the order of the cross-products, but you only need to worry about it at the very end; the yellow vector should point to the "right of the camera"; invert it if it doesn't.

This was one of the hardest screenshots I've tried to diagram over; I had given up on making it look right but will post it anyway, since I think you'll still get it.

enter image description here

Regarding quats:

Consider the specific wording of your question. "I want to rotate the image counter-clockwise". That's also saying that you want to rotate the camera clock-wise around CameraToObject. In that case, CameraToObject is the Quaternion's vector component, and "90 degrees" is the scalar component. Quaternions twist inputs around their vector component by the angle stored in their scalar component. Visualize the earth spinning on it's axis; it only has one axis to spin on so the only question left is "How much?"

added 269 characters in body
Source Link
Jon
  • 3.7k
  • 1
  • 13
  • 23
Loading
added 269 characters in body
Source Link
Jon
  • 3.7k
  • 1
  • 13
  • 23
Loading
added 269 characters in body
Source Link
Jon
  • 3.7k
  • 1
  • 13
  • 23
Loading
added 260 characters in body
Source Link
Jon
  • 3.7k
  • 1
  • 13
  • 23
Loading
Source Link
Jon
  • 3.7k
  • 1
  • 13
  • 23
Loading