Line 27: Line 27:
 
The tricky point to get to implement this method is to negate the 3d position of the sphere and use the distance to their centers as the ''d'' parameter.
 
The tricky point to get to implement this method is to negate the 3d position of the sphere and use the distance to their centers as the ''d'' parameter.
  
<html><iframe src="https://www.openprocessing.org/sketch/539606/embed/?plusEmbedHash=ZTk4N2UyMzUyM2U4ZDc5OWUzYmYyM2NkYjZjYTUwNGYyZGU0YTNhMjJlZDM0NTI2NzE2NzlmMzM4MThmZTRkNTU1NjFiOGU1ZjhjYThmNGJhMTlkYTgxNmJhZjJkM2NmYjI3OTBlNDBlNzBhYjNlZjFiNmI5NDg3MGRkMDYyOWYwU2ZqdDEvS2ZaMHJiaUtKeWY3WkJXVDRYQ1J1bUpBUXYzZklmSnRBTjQrU1Fid3NMbzhxSWlsbUU4Q0ZKT1dEQ1luRjZoVmVxY1FGcnZNR2g1dnBiZz09&plusEmbedTitle=true" width="600" height="400"></iframe><html>
+
<html><iframe src="https://www.openprocessing.org/sketch/539606/embed/?plusEmbedHash=ZTk4N2UyMzUyM2U4ZDc5OWUzYmYyM2NkYjZjYTUwNGYyZGU0YTNhMjJlZDM0NTI2NzE2NzlmMzM4MThmZTRkNTU1NjFiOGU1ZjhjYThmNGJhMTlkYTgxNmJhZjJkM2NmYjI3OTBlNDBlNzBhYjNlZjFiNmI5NDg3MGRkMDYyOWYwU2ZqdDEvS2ZaMHJiaUtKeWY3WkJXVDRYQ1J1bUpBUXYzZklmSnRBTjQrU1Fid3NMbzhxSWlsbUU4Q0ZKT1dEQ1luRjZoVmVxY1FGcnZNR2g1dnBiZz09" width="400" height="300"></iframe><html>
  
 
Implementation of the equation in an [https://www.openprocessing.org/sketch/539606 openprocessing] sketch.
 
Implementation of the equation in an [https://www.openprocessing.org/sketch/539606 openprocessing] sketch.

Revision as of 15:55, 19 April 2018

Notes about computation of inverse kinematics[1]

Solving-ik-001.png

At this moment, the research is focusing on solving a 2 bones system, the leg in this case, but it would be applicable on the arms or any other part of a skeleton having at least 2 parents.

The main issue seems to be the computation of the knee position. All distances are easily computed:

  • upper leg (red) keeps its length
  • leg (yellow) keeps its length also
  • distance between the target and the origin of the upper leg can be easily computed in world space.

Rendering the position of the knee is crucial to compute the rotation to apply on the upper leg. Once correct, the rotation of the leg will be simple to render, as it is the rotation from the current direction to the [knee - target] direction.

A little warning: the graphic here above is in 2d. In a 3d world, the position of the knee is a circle on a sphere: any point being at the right distance of the target point and the upperleg origin will be a valid candidate! The circle of possibilities is the intersection of 2 spheres having their radii equals to bones length.

Solving-ik-002.png

The radius of the cyan circle can be solved by using this equation[2]:

a = 1/(2d)sqrt(4d^2R^2-(d^2-r^2+R^2)^2) 

A little screenshot for better readability:

Sphere-Sphere Intersection.png

The tricky point to get to implement this method is to negate the 3d position of the sphere and use the distance to their centers as the d parameter.

Implementation of the equation in an [https://www.openprocessing.org/sketch/539606 openprocessing] sketch. We need to pick a point on this circle by using an arbitrary direction: * front axis of the leg or * knee - target difference. == References == * [https://www.youtube.com/watch?v=LNidsMesxSE Animation Bootcamp: An Indie Approach to Procedural Animation] - a [http://www.gdconf.com GDC] talk about character animation in a computation effective way. [[category:javascript]] [[category:avatar]] [[category:threejs]] [[category:3d]] [[category:animation]]
Cite error: <ref> tags exist, but no <references/> tag was found

online identity ∋ [ social ∋ [mastodon♥, twitter®, facebook®, diaspora, linkedin®] ∥ repos ∋ [github®, gitlab♥, bitbucket®, sourceforge] ∥ media ∋ [itch.io®, vimeo®, peertube♥, twitch.tv®, tumblr®] ∥ communities ∋ [godotengine♥, openprocessing, stackoverflow, threejs]]