# Spherical law of cosines help

## Recommended Posts

I was attempting to build a type of link system using the law of cosines and discovered that I need to use the "spherical law of cosines" instead for calculating this "spherical triangle" as seen below.

I was already at the limit of my limited math-in-Houdini skills and was really hoping someone could help me approach this the best way to obtain the data/measurements needed.

The simple image below represents a neutral position for three points.

•Each point (A,B,C) is a fixed distance from the center of a sphere.  Essentially creating a spherical triangle.

•Each point only rotates about one axis between it and the center of the sphere creating angles

•The A point is in a fixed position on the sphere and does not move.  Consider it a kind of base point

•The C point travels, with a limited range along the surface of the sphere(essentially rotating it's position from the center if the sphere).

•The distance between  A & B (AB) and B & C (BC) are both fixed lengths and function as arms.

•The B point essentially functions as an elbow and always stays the same distance between both A & C respectively as the C point moves.

Essentially I need C to be driven by XYZ rotations from the center of the sphere and for B to "chase it" like an elbow would "chase" a hand but within the constraints of it's single rotation and distances between A & C.

Using the Law of cosines (or in this case the Spherical Law of Cosines) I should be able to measure the new distance of CA to find all the angles of A, B & C (in Radians?).

Essentially a simple inverse kinematic that avoids using the Houdini bone system.

Since A is always a fixed point I should the be able to simply compare the neutral angle of A to the new one and use that difference to drive the animation necessary to rotate both A and B to position the the BC and AB sides/arms to once again align with the new C position.

I've included the scene below for reference but it's only a representation and the only potentially useful item is my measuring widget which unfortunately can't do radians at this point.

Thanks for any help or pointers.

Michael

Law_of_cosines.hip

##### Share on other sites

Accidentally put this in scripting.  Apologies to list moderators.  Will repost in general if that is alright.

## Create an account

Register a new account