@automovie/human 0.0.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (233) hide show
  1. package/README.md +29 -16
  2. package/lib/generation/AutoMovieHumanDigitJoints.d.ts +8 -26
  3. package/lib/generation/AutoMovieHumanDigitJoints.js +9 -37
  4. package/lib/generation/AutoMovieHumanDigitJoints.js.map +1 -1
  5. package/lib/generation/{AutoMovieHumanLegSection.d.ts → AutoMovieHumanLegSectionProportion.d.ts} +1 -1
  6. package/lib/generation/{AutoMovieHumanLegSection.js → AutoMovieHumanLegSectionProportion.js} +17 -14
  7. package/lib/generation/AutoMovieHumanLegSectionProportion.js.map +1 -0
  8. package/lib/generation/arm/AutoMovieHumanArmFrame.js +2 -2
  9. package/lib/generation/arm/AutoMovieHumanArmFrame.js.map +1 -1
  10. package/lib/generation/arm/index.d.ts +28 -0
  11. package/lib/generation/arm/index.js +45 -0
  12. package/lib/generation/arm/index.js.map +1 -0
  13. package/lib/generation/conic/AutoMovieHumanConicLoft.d.ts +154 -0
  14. package/lib/generation/conic/AutoMovieHumanConicLoft.js +430 -0
  15. package/lib/generation/conic/AutoMovieHumanConicLoft.js.map +1 -0
  16. package/lib/generation/conic/AutoMovieHumanConicPose.d.ts +92 -0
  17. package/lib/generation/conic/AutoMovieHumanConicPose.js +202 -0
  18. package/lib/generation/conic/AutoMovieHumanConicPose.js.map +1 -0
  19. package/lib/generation/conic/AutoMovieHumanConicRelief.d.ts +52 -0
  20. package/lib/generation/conic/AutoMovieHumanConicRelief.js +88 -0
  21. package/lib/generation/conic/AutoMovieHumanConicRelief.js.map +1 -0
  22. package/lib/generation/conic/AutoMovieHumanConicSection.d.ts +252 -0
  23. package/lib/generation/conic/AutoMovieHumanConicSection.js +567 -0
  24. package/lib/generation/conic/AutoMovieHumanConicSection.js.map +1 -0
  25. package/lib/generation/f1/AutoMovieHumanF1.d.ts +265 -0
  26. package/lib/generation/f1/AutoMovieHumanF1.js +1254 -0
  27. package/lib/generation/f1/AutoMovieHumanF1.js.map +1 -0
  28. package/lib/generation/f1/AutoMovieHumanF1Antihelix.d.ts +23 -0
  29. package/lib/generation/f1/AutoMovieHumanF1Antihelix.js +65 -0
  30. package/lib/generation/f1/AutoMovieHumanF1Antihelix.js.map +1 -0
  31. package/lib/generation/f1/AutoMovieHumanF1Arm.d.ts +18 -0
  32. package/lib/generation/f1/AutoMovieHumanF1Arm.js +82 -0
  33. package/lib/generation/f1/AutoMovieHumanF1Arm.js.map +1 -0
  34. package/lib/generation/f1/AutoMovieHumanF1Axilla.d.ts +18 -0
  35. package/lib/generation/f1/AutoMovieHumanF1Axilla.js +91 -0
  36. package/lib/generation/f1/AutoMovieHumanF1Axilla.js.map +1 -0
  37. package/lib/generation/f1/AutoMovieHumanF1Breast.d.ts +18 -0
  38. package/lib/generation/f1/AutoMovieHumanF1Breast.js +75 -0
  39. package/lib/generation/f1/AutoMovieHumanF1Breast.js.map +1 -0
  40. package/lib/generation/f1/AutoMovieHumanF1Concha.d.ts +40 -0
  41. package/lib/generation/f1/AutoMovieHumanF1Concha.js +81 -0
  42. package/lib/generation/f1/AutoMovieHumanF1Concha.js.map +1 -0
  43. package/lib/generation/f1/AutoMovieHumanF1FingerIndex.d.ts +18 -0
  44. package/lib/generation/f1/AutoMovieHumanF1FingerIndex.js +59 -0
  45. package/lib/generation/f1/AutoMovieHumanF1FingerIndex.js.map +1 -0
  46. package/lib/generation/f1/AutoMovieHumanF1FingerMiddle.d.ts +18 -0
  47. package/lib/generation/f1/AutoMovieHumanF1FingerMiddle.js +59 -0
  48. package/lib/generation/f1/AutoMovieHumanF1FingerMiddle.js.map +1 -0
  49. package/lib/generation/f1/AutoMovieHumanF1FingerPinky.d.ts +18 -0
  50. package/lib/generation/f1/AutoMovieHumanF1FingerPinky.js +75 -0
  51. package/lib/generation/f1/AutoMovieHumanF1FingerPinky.js.map +1 -0
  52. package/lib/generation/f1/AutoMovieHumanF1FingerRing.d.ts +18 -0
  53. package/lib/generation/f1/AutoMovieHumanF1FingerRing.js +75 -0
  54. package/lib/generation/f1/AutoMovieHumanF1FingerRing.js.map +1 -0
  55. package/lib/generation/f1/AutoMovieHumanF1FingerThumb.d.ts +18 -0
  56. package/lib/generation/f1/AutoMovieHumanF1FingerThumb.js +59 -0
  57. package/lib/generation/f1/AutoMovieHumanF1FingerThumb.js.map +1 -0
  58. package/lib/generation/f1/AutoMovieHumanF1Frames.d.ts +97 -0
  59. package/lib/generation/f1/AutoMovieHumanF1Frames.js +160 -0
  60. package/lib/generation/f1/AutoMovieHumanF1Frames.js.map +1 -0
  61. package/lib/generation/f1/AutoMovieHumanF1Hand.d.ts +18 -0
  62. package/lib/generation/f1/AutoMovieHumanF1Hand.js +81 -0
  63. package/lib/generation/f1/AutoMovieHumanF1Hand.js.map +1 -0
  64. package/lib/generation/f1/AutoMovieHumanF1Helix.d.ts +20 -0
  65. package/lib/generation/f1/AutoMovieHumanF1Helix.js +64 -0
  66. package/lib/generation/f1/AutoMovieHumanF1Helix.js.map +1 -0
  67. package/lib/generation/f1/AutoMovieHumanF1Joints.d.ts +231 -0
  68. package/lib/generation/f1/AutoMovieHumanF1Joints.js +249 -0
  69. package/lib/generation/f1/AutoMovieHumanF1Joints.js.map +1 -0
  70. package/lib/generation/f1/AutoMovieHumanF1Landmarks.d.ts +86 -0
  71. package/lib/generation/f1/AutoMovieHumanF1Landmarks.js +89 -0
  72. package/lib/generation/f1/AutoMovieHumanF1Landmarks.js.map +1 -0
  73. package/lib/generation/f1/AutoMovieHumanF1Leg.d.ts +18 -0
  74. package/lib/generation/f1/AutoMovieHumanF1Leg.js +82 -0
  75. package/lib/generation/f1/AutoMovieHumanF1Leg.js.map +1 -0
  76. package/lib/generation/f1/AutoMovieHumanF1Nose.d.ts +18 -0
  77. package/lib/generation/f1/AutoMovieHumanF1Nose.js +82 -0
  78. package/lib/generation/f1/AutoMovieHumanF1Nose.js.map +1 -0
  79. package/lib/generation/f1/AutoMovieHumanF1Nostril.d.ts +18 -0
  80. package/lib/generation/f1/AutoMovieHumanF1Nostril.js +59 -0
  81. package/lib/generation/f1/AutoMovieHumanF1Nostril.js.map +1 -0
  82. package/lib/generation/f1/AutoMovieHumanF1Placement.d.ts +75 -0
  83. package/lib/generation/f1/AutoMovieHumanF1Placement.js +151 -0
  84. package/lib/generation/f1/AutoMovieHumanF1Placement.js.map +1 -0
  85. package/lib/generation/f1/AutoMovieHumanF1Placing.d.ts +45 -0
  86. package/lib/generation/f1/AutoMovieHumanF1Placing.js +301 -0
  87. package/lib/generation/f1/AutoMovieHumanF1Placing.js.map +1 -0
  88. package/lib/generation/f1/AutoMovieHumanF1Plate.d.ts +18 -0
  89. package/lib/generation/f1/AutoMovieHumanF1Plate.js +59 -0
  90. package/lib/generation/f1/AutoMovieHumanF1Plate.js.map +1 -0
  91. package/lib/generation/f1/AutoMovieHumanF1ToeBig.d.ts +18 -0
  92. package/lib/generation/f1/AutoMovieHumanF1ToeBig.js +59 -0
  93. package/lib/generation/f1/AutoMovieHumanF1ToeBig.js.map +1 -0
  94. package/lib/generation/f1/AutoMovieHumanF1ToeIndex.d.ts +18 -0
  95. package/lib/generation/f1/AutoMovieHumanF1ToeIndex.js +59 -0
  96. package/lib/generation/f1/AutoMovieHumanF1ToeIndex.js.map +1 -0
  97. package/lib/generation/f1/AutoMovieHumanF1ToeLittle.d.ts +18 -0
  98. package/lib/generation/f1/AutoMovieHumanF1ToeLittle.js +75 -0
  99. package/lib/generation/f1/AutoMovieHumanF1ToeLittle.js.map +1 -0
  100. package/lib/generation/f1/AutoMovieHumanF1ToeMiddle.d.ts +18 -0
  101. package/lib/generation/f1/AutoMovieHumanF1ToeMiddle.js +75 -0
  102. package/lib/generation/f1/AutoMovieHumanF1ToeMiddle.js.map +1 -0
  103. package/lib/generation/f1/AutoMovieHumanF1ToeRing.d.ts +18 -0
  104. package/lib/generation/f1/AutoMovieHumanF1ToeRing.js +75 -0
  105. package/lib/generation/f1/AutoMovieHumanF1ToeRing.js.map +1 -0
  106. package/lib/generation/f1/AutoMovieHumanF1Trunk.d.ts +18 -0
  107. package/lib/generation/f1/AutoMovieHumanF1Trunk.js +79 -0
  108. package/lib/generation/f1/AutoMovieHumanF1Trunk.js.map +1 -0
  109. package/lib/generation/f1/AutoMovieHumanF1Vault.d.ts +18 -0
  110. package/lib/generation/f1/AutoMovieHumanF1Vault.js +75 -0
  111. package/lib/generation/f1/AutoMovieHumanF1Vault.js.map +1 -0
  112. package/lib/generation/foot/index.d.ts +51 -0
  113. package/lib/generation/foot/index.js +68 -0
  114. package/lib/generation/foot/index.js.map +1 -0
  115. package/lib/generation/frame/AutoMovieHumanSegmentFrame.d.ts +149 -0
  116. package/lib/generation/frame/AutoMovieHumanSegmentFrame.js +290 -0
  117. package/lib/generation/frame/AutoMovieHumanSegmentFrame.js.map +1 -0
  118. package/lib/generation/hand/index.d.ts +53 -0
  119. package/lib/generation/hand/index.js +70 -0
  120. package/lib/generation/hand/index.js.map +1 -0
  121. package/lib/generation/head/index.d.ts +37 -0
  122. package/lib/generation/head/index.js +54 -0
  123. package/lib/generation/head/index.js.map +1 -0
  124. package/lib/generation/index.d.ts +176 -0
  125. package/lib/generation/index.js +193 -0
  126. package/lib/generation/index.js.map +1 -0
  127. package/lib/generation/leg/AutoMovieHumanLegLaws.d.ts +1 -1
  128. package/lib/generation/leg/AutoMovieHumanLegLaws.js +23 -11
  129. package/lib/generation/leg/AutoMovieHumanLegLaws.js.map +1 -1
  130. package/lib/generation/leg/index.d.ts +34 -0
  131. package/lib/generation/leg/index.js +51 -0
  132. package/lib/generation/leg/index.js.map +1 -0
  133. package/lib/generation/limb/{AutoMovieHumanJointTurn.d.ts → AutoMovieHumanBendArc.d.ts} +1 -1
  134. package/lib/generation/limb/{AutoMovieHumanJointTurn.js → AutoMovieHumanBendArc.js} +12 -8
  135. package/lib/generation/limb/AutoMovieHumanBendArc.js.map +1 -0
  136. package/lib/generation/limb/AutoMovieHumanDigitWalk.js +2 -2
  137. package/lib/generation/limb/AutoMovieHumanDigitWalk.js.map +1 -1
  138. package/lib/generation/limb/AutoMovieHumanWalkPart.js +72 -17
  139. package/lib/generation/limb/AutoMovieHumanWalkPart.js.map +1 -1
  140. package/lib/generation/limb/index.d.ts +12 -0
  141. package/lib/generation/limb/index.js +29 -0
  142. package/lib/generation/limb/index.js.map +1 -0
  143. package/lib/generation/trunk/index.d.ts +17 -0
  144. package/lib/generation/trunk/index.js +34 -0
  145. package/lib/generation/trunk/index.js.map +1 -0
  146. package/lib/generation/web/index.d.ts +14 -0
  147. package/lib/generation/web/index.js +31 -0
  148. package/lib/generation/web/index.js.map +1 -0
  149. package/lib/index.d.ts +14 -4
  150. package/lib/index.js +14 -9
  151. package/lib/index.js.map +1 -1
  152. package/lib/lofting/index.d.ts +14 -0
  153. package/lib/lofting/index.js +31 -0
  154. package/lib/lofting/index.js.map +1 -0
  155. package/lib/skeleton/AutoMovieHumanCanonicalBody.d.ts +7 -3
  156. package/lib/skeleton/AutoMovieHumanCanonicalBody.js +31 -3
  157. package/lib/skeleton/AutoMovieHumanCanonicalBody.js.map +1 -1
  158. package/lib/skeleton/AutoMovieHumanCanonicalProfile.d.ts +22 -31
  159. package/lib/skeleton/AutoMovieHumanCanonicalProfile.js +112 -172
  160. package/lib/skeleton/AutoMovieHumanCanonicalProfile.js.map +1 -1
  161. package/lib/skeleton/AutoMovieHumanCanonicalSolids.d.ts +65 -0
  162. package/lib/skeleton/AutoMovieHumanCanonicalSolids.js +105 -0
  163. package/lib/skeleton/AutoMovieHumanCanonicalSolids.js.map +1 -0
  164. package/lib/skeleton/index.d.ts +29 -0
  165. package/lib/skeleton/index.js +46 -0
  166. package/lib/skeleton/index.js.map +1 -0
  167. package/lib/structures/index.d.ts +2 -2
  168. package/lib/structures/index.js +2 -2
  169. package/lib/structures/index.js.map +1 -1
  170. package/lib/typings/index.d.ts +1 -1
  171. package/lib/typings/index.js +1 -1
  172. package/lib/typings/index.js.map +1 -1
  173. package/package.json +21 -13
  174. package/src/generation/AutoMovieHumanDigitJoints.ts +12 -47
  175. package/src/generation/{AutoMovieHumanLegSection.ts → AutoMovieHumanLegSectionProportion.ts} +15 -6
  176. package/src/generation/arm/AutoMovieHumanArmFrame.ts +2 -2
  177. package/src/generation/arm/index.ts +28 -0
  178. package/src/generation/conic/AutoMovieHumanConicLoft.ts +566 -0
  179. package/src/generation/conic/AutoMovieHumanConicPose.ts +213 -0
  180. package/src/generation/conic/AutoMovieHumanConicRelief.ts +94 -0
  181. package/src/generation/conic/AutoMovieHumanConicSection.ts +609 -0
  182. package/src/generation/f1/AutoMovieHumanF1.ts +1448 -0
  183. package/src/generation/f1/AutoMovieHumanF1Antihelix.ts +64 -0
  184. package/src/generation/f1/AutoMovieHumanF1Arm.ts +82 -0
  185. package/src/generation/f1/AutoMovieHumanF1Axilla.ts +90 -0
  186. package/src/generation/f1/AutoMovieHumanF1Breast.ts +74 -0
  187. package/src/generation/f1/AutoMovieHumanF1Concha.ts +80 -0
  188. package/src/generation/f1/AutoMovieHumanF1FingerIndex.ts +58 -0
  189. package/src/generation/f1/AutoMovieHumanF1FingerMiddle.ts +58 -0
  190. package/src/generation/f1/AutoMovieHumanF1FingerPinky.ts +74 -0
  191. package/src/generation/f1/AutoMovieHumanF1FingerRing.ts +74 -0
  192. package/src/generation/f1/AutoMovieHumanF1FingerThumb.ts +58 -0
  193. package/src/generation/f1/AutoMovieHumanF1Frames.ts +191 -0
  194. package/src/generation/f1/AutoMovieHumanF1Hand.ts +81 -0
  195. package/src/generation/f1/AutoMovieHumanF1Helix.ts +63 -0
  196. package/src/generation/f1/AutoMovieHumanF1Joints.ts +319 -0
  197. package/src/generation/f1/AutoMovieHumanF1Landmarks.ts +101 -0
  198. package/src/generation/f1/AutoMovieHumanF1Leg.ts +82 -0
  199. package/src/generation/f1/AutoMovieHumanF1Nose.ts +82 -0
  200. package/src/generation/f1/AutoMovieHumanF1Nostril.ts +58 -0
  201. package/src/generation/f1/AutoMovieHumanF1Placement.ts +148 -0
  202. package/src/generation/f1/AutoMovieHumanF1Placing.ts +313 -0
  203. package/src/generation/f1/AutoMovieHumanF1Plate.ts +59 -0
  204. package/src/generation/f1/AutoMovieHumanF1ToeBig.ts +58 -0
  205. package/src/generation/f1/AutoMovieHumanF1ToeIndex.ts +58 -0
  206. package/src/generation/f1/AutoMovieHumanF1ToeLittle.ts +74 -0
  207. package/src/generation/f1/AutoMovieHumanF1ToeMiddle.ts +74 -0
  208. package/src/generation/f1/AutoMovieHumanF1ToeRing.ts +74 -0
  209. package/src/generation/f1/AutoMovieHumanF1Trunk.ts +79 -0
  210. package/src/generation/f1/AutoMovieHumanF1Vault.ts +74 -0
  211. package/src/generation/foot/index.ts +51 -0
  212. package/src/generation/frame/AutoMovieHumanSegmentFrame.ts +309 -0
  213. package/src/generation/hand/index.ts +53 -0
  214. package/src/generation/head/index.ts +37 -0
  215. package/src/generation/index.ts +176 -0
  216. package/src/generation/leg/AutoMovieHumanLegLaws.ts +80 -25
  217. package/src/generation/leg/index.ts +34 -0
  218. package/src/generation/limb/{AutoMovieHumanJointTurn.ts → AutoMovieHumanBendArc.ts} +39 -11
  219. package/src/generation/limb/AutoMovieHumanDigitWalk.ts +2 -2
  220. package/src/generation/limb/AutoMovieHumanWalkPart.ts +163 -41
  221. package/src/generation/limb/index.ts +12 -0
  222. package/src/generation/trunk/index.ts +17 -0
  223. package/src/generation/web/index.ts +14 -0
  224. package/src/index.ts +14 -4
  225. package/src/lofting/index.ts +14 -0
  226. package/src/skeleton/AutoMovieHumanCanonicalBody.ts +53 -3
  227. package/src/skeleton/AutoMovieHumanCanonicalProfile.ts +153 -358
  228. package/src/skeleton/AutoMovieHumanCanonicalSolids.ts +175 -0
  229. package/src/skeleton/index.ts +29 -0
  230. package/src/structures/index.ts +2 -2
  231. package/src/typings/index.ts +1 -1
  232. package/lib/generation/AutoMovieHumanLegSection.js.map +0 -1
  233. package/lib/generation/limb/AutoMovieHumanJointTurn.js.map +0 -1
@@ -5,6 +5,7 @@ import {
5
5
  HUMANOID_REST_FRAME,
6
6
  Quaternion,
7
7
  Vector3,
8
+ combinePhysicalMassProperties,
8
9
  rotationBetween,
9
10
  toRigAngle,
10
11
  } from "@automovie/engine";
@@ -16,25 +17,24 @@ import type {
16
17
  IAutoMoviePhysicalProfile as P,
17
18
  } from "@automovie/interface";
18
19
 
20
+ import { AutoMovieHumanCanonicalSolids as Solids } from "./AutoMovieHumanCanonicalSolids";
21
+
19
22
  /**
20
23
  * The contact and mass profile of a polygon man, built from the same joints
21
24
  * and girth radii its drawing is built from, at the canonical T-pose rest.
22
25
  *
23
- * Colliders follow the drawn primitives: each limb segment and each phalanx
24
- * is a capsule of its girth radius whose axis runs from its joint to its child
25
- * joint, so its caps are the drawn joint balls and every joint lies inside its
26
- * own segment's collider, while a capsule to a surface tip (a distal phalanx
27
- * to its fingertip, the head to its crown) ends with its cap on the tip, so
28
- * the stature and the fingertips are where they are drawn; the pelvis, abdomen
29
- * and thorax are boxes between their joints whose half breadths and half
30
- * depths are the drawing's elliptical sections scaled by `sqrt(pi / 4)` (a box
31
- * of the ellipse's area); the neck is a capsule to the head joint and the head
32
- * a capsule from the head joint to the crown; the palm is a box from the wrist
33
- * to the finger roots' balls, as broad as the finger roots; the rear foot is
34
- * the box of the ankle, subtalar and midfoot joints' spheres and the toe
35
- * roots' (the ball), standing on the floor, and the toes the box of the toe
36
- * joints' spheres to their tips, riding the toes bone so they bend at the
37
- * ball as the drawn toes do.
26
+ * Colliders are the drawn solids. The trunk, the neck, the head, each limb
27
+ * segment, the palm, the rear foot and every toe phalanx collide as the
28
+ * convex hulls of the very ring points the drawing lofts its mesh through
29
+ * (`AutoMovieHumanCanonicalSolids`), so the collision surface is the drawn
30
+ * surface: no corner stands outside what is seen and no drawn surface lies
31
+ * outside its collider. A rig bone carries the hulls of every drawn module
32
+ * that rides it: the foot its two modules through the subtalar and midfoot
33
+ * joints, the toes bone every toe phalanx, so the toes bend at the ball as
34
+ * drawn. Each phalanx of the hand is a capsule of its girth radius from its
35
+ * joint to its child joint, a distal one ending with its cap on the
36
+ * fingertip, because a curl solves its contact in closed form on capsules
37
+ * and the drawn phalanx is that round.
38
38
  *
39
39
  * Masses are Dempster's shares of body mass as tabulated by Winter
40
40
  * (Biomechanics and Motor Control of Human Movement, 4th ed., table 4.1):
@@ -42,33 +42,24 @@ import type {
42
42
  * 0.0145, thorax 0.216, abdomen 0.139, pelvis 0.142 and head with neck 0.081,
43
43
  * the head taking de Leva's (1996) 0.0694 and the neck the rest; the hand's
44
44
  * share is split over the palm and the phalanges by collider volume, a
45
- * uniform density within the hand, and the foot's over the rear foot and
46
- * the toes by box volume. Each
47
- * segment's centre of mass is its collider's centre and its inertia the
48
- * collider's as a uniform solid, the way physics engines derive inertia from
49
- * shapes. Joints sit at each child joint with identity frames; every clinical
50
- * axis of `DEFAULT_HUMANOID_ROM` becomes a physical axis along its
45
+ * uniform density within the hand, and the foot's over the rear foot and the
46
+ * toes the same way. Each segment's centre of mass and inertia are those of
47
+ * its colliders as uniform solids, combined by the parallel-axis theorem,
48
+ * the way physics engines derive inertia from shapes. Joints sit at each
49
+ * child joint with identity frames; every clinical axis of
50
+ * `DEFAULT_HUMANOID_ROM` becomes a physical axis along its
51
51
  * `HUMANOID_JOINT_AXES` direction with limits read through
52
52
  * `HUMANOID_REST_FRAME`, so the physical zero is the T-pose. Drive gains are
53
53
  * placeholders kinematic motion never reads: 50 N m per downstream kilogram.
54
54
  */
55
55
  export namespace AutoMovieHumanCanonicalProfile {
56
56
  /** One drawn joint: its canonical rest position, its girth radius and its carrier. */
57
- export interface IJoint {
58
- /** Rest joint centre, canonical metres. */
59
- position: IAutoMovieVector3;
60
-
61
- /** Rest tip of a leaf segment, canonical metres. */
62
- tip: IAutoMovieVector3 | null;
63
-
64
- /** Girth radius, metres. */
65
- radius: number;
66
- }
57
+ export type IJoint = Solids.IJoint;
67
58
 
68
59
  /**
69
60
  * Build the profile.
70
61
  *
71
- * @param joints Every drawn Human joint by id.
62
+ * @param joints Every drawn Human joint by id, parent before child.
72
63
  * @param mass Body mass, kilograms.
73
64
  * @param id Profile id.
74
65
  * @returns The profile on the rig's bones.
@@ -84,69 +75,39 @@ export namespace AutoMovieHumanCanonicalProfile {
84
75
  throw new Error(`The polygon profile needs the joint ${name}`);
85
76
  return found;
86
77
  };
87
- const k: number = Math.sqrt(Math.PI / 4);
88
78
  const identity: IAutoMovieQuaternion = Quaternion.identity();
89
- const segments: P.ISegment[] = [];
90
- const add = (
91
- bone: AutoMovieHumanoidBone,
92
- share: number,
93
- shape: P.IShape,
94
- inertia: IAutoMovieVector3,
95
- origin: IAutoMovieVector3 = j(bone).position,
96
- ): void => {
97
- const m: number = share * mass;
98
- segments.push({
99
- bone,
100
- neutral: { position: origin, rotation: identity },
101
- mass: m,
102
- centerOfMass: shape.transform.position,
103
- inertia: Vector3.scale(inertia, m),
104
- inertiaRotation: shape.transform.rotation,
105
- shapes: [shape],
106
- });
79
+ const at = (name: string): IAutoMovieVector3 => j(name).position;
80
+ // A rig bone's origin is its joint; the toes bone sits at the hallux's root.
81
+ const origin = (bone: AutoMovieHumanoidBone): IAutoMovieVector3 =>
82
+ at(bone.replace(/Toes$/u, "HalluxProximal"));
83
+ const parts: Map<AutoMovieHumanoidBone, IPart[]> = new Map();
84
+ const put = (bone: AutoMovieHumanoidBone, part: IPart): void => {
85
+ parts.set(bone, [...(parts.get(bone) ?? []), part]);
107
86
  };
108
- const box = (
109
- bone: AutoMovieHumanoidBone,
110
- share: number,
111
- min: IAutoMovieVector3,
112
- max: IAutoMovieVector3,
113
- origin: IAutoMovieVector3 = j(bone).position,
114
- ): void => {
115
- const half: IAutoMovieVector3 = Vector3.scale(
116
- Vector3.subtract(max, min),
117
- 0.5,
118
- );
119
- const centre: IAutoMovieVector3 = Vector3.subtract(
120
- Vector3.scale(Vector3.add(min, max), 0.5),
121
- origin,
122
- );
123
- add(
124
- bone,
125
- share,
126
- {
127
- id: "body",
87
+ for (const solid of Solids.build(joints))
88
+ put(solid.carrier, {
89
+ shape: {
90
+ id: solid.id,
128
91
  material: "skin",
129
- transform: { position: centre, rotation: identity },
130
- kind: "box",
131
- halfExtents: half,
92
+ transform: {
93
+ position: Vector3.subtract(solid.centre, origin(solid.carrier)),
94
+ rotation: identity,
95
+ },
96
+ kind: "hull",
97
+ points: solid.points,
132
98
  },
133
- {
134
- x: (half.y ** 2 + half.z ** 2) / 3,
135
- y: (half.x ** 2 + half.z ** 2) / 3,
136
- z: (half.x ** 2 + half.y ** 2) / 3,
137
- },
138
- origin,
139
- );
140
- };
141
- // A capsule between two joints ends in the joints' balls; one to a surface
142
- // tip (the crown, a fingertip) ends with its cap on the tip.
99
+ volume: solid.volume,
100
+ inertia: solid.inertia,
101
+ inertiaRotation: solid.inertiaRotation,
102
+ });
103
+ // A phalanx between two joints ends in the joints' balls; a distal one
104
+ // ends with its cap on the fingertip.
143
105
  const capsule = (
144
106
  bone: AutoMovieHumanoidBone,
145
- share: number,
146
107
  from: IAutoMovieVector3,
147
108
  end: IAutoMovieVector3,
148
109
  radius: number,
149
- tip: boolean = false,
110
+ tip: boolean,
150
111
  ): void => {
151
112
  const span: number = Vector3.length(Vector3.subtract(end, from));
152
113
  const inward: number = tip ? Math.min(radius, span) : 0;
@@ -161,267 +122,29 @@ export namespace AutoMovieHumanCanonicalProfile {
161
122
  const length: number = Vector3.length(axis);
162
123
  const rotation: IAutoMovieQuaternion =
163
124
  length > 1e-9 ? rotationBetween({ x: 0, y: 1, z: 0 }, axis) : identity;
164
- const centre: IAutoMovieVector3 = Vector3.subtract(
165
- Vector3.scale(Vector3.add(from, to), 0.5),
166
- j(bone).position,
167
- );
168
- const half: number = length / 2;
169
- const full: number = 2 * half + 2 * radius;
170
- const axial: number = (radius * radius) / 2;
125
+ const full: number = length + 2 * radius;
171
126
  const transverse: number = (3 * radius * radius + full * full) / 12;
172
- add(
173
- bone,
174
- share,
175
- {
127
+ put(bone, {
128
+ shape: {
176
129
  id: "body",
177
130
  material: "skin",
178
- transform: { position: centre, rotation },
131
+ transform: {
132
+ position: Vector3.subtract(
133
+ Vector3.scale(Vector3.add(from, to), 0.5),
134
+ origin(bone),
135
+ ),
136
+ rotation,
137
+ },
179
138
  kind: "capsule",
180
139
  radius,
181
- halfLength: half,
140
+ halfLength: length / 2,
182
141
  },
183
- { x: transverse, y: axial, z: transverse },
184
- );
142
+ volume:
143
+ Math.PI * radius * radius * length + (4 / 3) * Math.PI * radius ** 3,
144
+ inertia: { x: transverse, y: (radius * radius) / 2, z: transverse },
145
+ inertiaRotation: rotation,
146
+ });
185
147
  };
186
- const at = (name: string): IAutoMovieVector3 => j(name).position;
187
- const span = (a: string, b: string): number =>
188
- Math.abs(at(a).x - at(b).x) / 2;
189
-
190
- // Trunk boxes from the drawing's sections (half breadth, half depth = girth radius).
191
- const hips: IJoint = j("hips");
192
- const spine: IJoint = j("spine");
193
- const chest: IJoint = j("chest");
194
- const legRadius: number = Math.max(
195
- j("leftUpperLeg").radius,
196
- j("rightUpperLeg").radius,
197
- );
198
- const armRadius: number = Math.max(
199
- j("leftUpperArm").radius,
200
- j("rightUpperArm").radius,
201
- );
202
- const hipBreadth: number = Math.max(
203
- hips.radius,
204
- span("leftUpperLeg", "rightUpperLeg") + legRadius,
205
- );
206
- const shoulderBreadth: number = Math.max(
207
- chest.radius,
208
- span("leftUpperArm", "rightUpperArm") + armRadius,
209
- );
210
- const lumbar: number = Math.max(spine.radius, 0.75 * shoulderBreadth);
211
- const thorax: number = Math.max(chest.radius, 0.85 * shoulderBreadth);
212
- const trunk = (
213
- bone: AutoMovieHumanoidBone,
214
- share: number,
215
- bottom: number,
216
- top: number,
217
- breadth: number,
218
- depth: number,
219
- z: number,
220
- ): void =>
221
- box(
222
- bone,
223
- share,
224
- { x: -k * breadth, y: bottom, z: z - k * depth },
225
- { x: k * breadth, y: top, z: z + k * depth },
226
- );
227
- trunk(
228
- "hips",
229
- 0.142,
230
- hips.position.y -
231
- Math.min(j("leftUpperLeg").radius, j("rightUpperLeg").radius),
232
- spine.position.y,
233
- hipBreadth,
234
- hips.radius,
235
- hips.position.z,
236
- );
237
- trunk(
238
- "spine",
239
- 0.139,
240
- spine.position.y,
241
- chest.position.y,
242
- (lumbar + thorax) / 2,
243
- (spine.radius + chest.radius) / 2,
244
- spine.position.z,
245
- );
246
- trunk(
247
- "chest",
248
- 0.216,
249
- chest.position.y,
250
- at("neck").y,
251
- (thorax + shoulderBreadth) / 2,
252
- chest.radius,
253
- chest.position.z,
254
- );
255
- capsule("neck", 0.081 - 0.0694, at("neck"), at("head"), j("neck").radius);
256
- const crown: IAutoMovieVector3 =
257
- j("head").tip ??
258
- Vector3.add(at("head"), { x: 0, y: 2 * j("head").radius, z: 0 });
259
- capsule(
260
- "head",
261
- 0.0694,
262
- at("head"),
263
- crown,
264
- j("head").radius,
265
- j("head").tip !== null,
266
- );
267
-
268
- for (const side of ["left", "right"] as const) {
269
- const b = (name: string): AutoMovieHumanoidBone =>
270
- `${side}${name}` as AutoMovieHumanoidBone;
271
- capsule(
272
- b("UpperArm"),
273
- 0.028,
274
- at(b("UpperArm")),
275
- at(b("LowerArm")),
276
- j(b("UpperArm")).radius,
277
- );
278
- capsule(
279
- b("LowerArm"),
280
- 0.016,
281
- at(b("LowerArm")),
282
- at(b("Hand")),
283
- j(b("LowerArm")).radius,
284
- );
285
- const knuckles: IJoint[] = FINGERS.map(
286
- (d: string): IJoint => j(b(`${d}Proximal`)),
287
- );
288
- const across: number =
289
- Math.abs(at(b("IndexProximal")).z - at(b("LittleProximal")).z) / 2 +
290
- j(b("IndexProximal")).radius;
291
- const thick: number = k * j(b("Hand")).radius;
292
- const wrist: IAutoMovieVector3 = at(b("Hand"));
293
- const xs: number[] = [
294
- wrist.x,
295
- ...knuckles.flatMap((n: IJoint): number[] => [
296
- n.position.x - n.radius,
297
- n.position.x + n.radius,
298
- ]),
299
- ];
300
- const digits: {
301
- bone: AutoMovieHumanoidBone;
302
- from: IAutoMovieVector3;
303
- to: IAutoMovieVector3;
304
- radius: number;
305
- tip: boolean;
306
- }[] = DIGITS.flatMap((chain: readonly string[]) =>
307
- chain.map((name: string, i: number) => {
308
- const joint: IJoint = j(b(name));
309
- const next: string | undefined = chain[i + 1];
310
- return {
311
- bone: b(name),
312
- from: joint.position,
313
- to:
314
- next === undefined ? (joint.tip ?? joint.position) : at(b(next)),
315
- tip: next === undefined && joint.tip !== null,
316
- radius: joint.radius,
317
- };
318
- }),
319
- );
320
- // The hand's Dempster share split over its palm and phalanges by volume (uniform density).
321
- const palmHalf: IAutoMovieVector3 = {
322
- x: (Math.max(...xs) - Math.min(...xs)) / 2,
323
- y: thick,
324
- z: across,
325
- };
326
- const capsuleVolume = (r: number, length: number): number =>
327
- Math.PI * r * r * length + (4 / 3) * Math.PI * r ** 3;
328
- const volumes: number[] = digits.map((d): number =>
329
- capsuleVolume(d.radius, Vector3.length(Vector3.subtract(d.to, d.from))),
330
- );
331
- const palmVolume: number = 8 * palmHalf.x * palmHalf.y * palmHalf.z;
332
- const handVolume: number =
333
- palmVolume + volumes.reduce((s: number, v: number): number => s + v, 0);
334
- box(
335
- b("Hand"),
336
- (0.006 * palmVolume) / handVolume,
337
- { x: Math.min(...xs), y: wrist.y - thick, z: wrist.z - across },
338
- { x: Math.max(...xs), y: wrist.y + thick, z: wrist.z + across },
339
- );
340
- digits.forEach((d, i: number): void =>
341
- capsule(
342
- d.bone,
343
- (0.006 * volumes[i]!) / handVolume,
344
- d.from,
345
- d.to,
346
- d.radius,
347
- d.tip,
348
- ),
349
- );
350
- capsule(
351
- b("UpperLeg"),
352
- 0.1,
353
- at(b("UpperLeg")),
354
- at(b("LowerLeg")),
355
- j(b("UpperLeg")).radius,
356
- );
357
- capsule(
358
- b("LowerLeg"),
359
- 0.0465,
360
- at(b("LowerLeg")),
361
- at(b("Foot")),
362
- j(b("LowerLeg")).radius,
363
- );
364
- // The rear foot to the balls of the toes' roots, and the toes from their roots to their tips.
365
- const named = (pattern: RegExp): IJoint[] =>
366
- [...joints.entries()]
367
- .filter(
368
- ([name]): boolean => name.startsWith(side) && pattern.test(name),
369
- )
370
- .map(([, joint]): IJoint => joint);
371
- const roots: IJoint[] = named(/(HalluxProximal|Toe\dProximal)$/);
372
- const extent = (
373
- parts: IJoint[],
374
- floor: number,
375
- top: number,
376
- tips: boolean,
377
- ): { min: IAutoMovieVector3; max: IAutoMovieVector3 } => {
378
- const min: IAutoMovieVector3 = { x: Infinity, y: floor, z: Infinity };
379
- const max: IAutoMovieVector3 = { x: -Infinity, y: top, z: -Infinity };
380
- for (const joint of parts)
381
- for (const p of [
382
- joint.position,
383
- ...(tips && joint.tip !== null ? [joint.tip] : []),
384
- ]) {
385
- min.x = Math.min(min.x, p.x - joint.radius);
386
- min.z = Math.min(min.z, p.z - joint.radius);
387
- max.x = Math.max(max.x, p.x + joint.radius);
388
- max.z = Math.max(max.z, p.z + joint.radius);
389
- }
390
- return { min, max };
391
- };
392
- const toes: IJoint[] = named(/(Hallux|Toe\d)/);
393
- const rear = extent(
394
- [...named(/(Foot|Subtalar|Midfoot)$/), ...roots],
395
- 0,
396
- at(b("Foot")).y,
397
- false,
398
- );
399
- const front = extent(
400
- toes,
401
- Math.min(
402
- ...toes.map(
403
- (t: IJoint): number =>
404
- Math.min(t.position.y, t.tip?.y ?? Infinity) - t.radius,
405
- ),
406
- ),
407
- Math.max(...toes.map((t: IJoint): number => t.position.y + t.radius)),
408
- true,
409
- );
410
- const volume = (e: {
411
- min: IAutoMovieVector3;
412
- max: IAutoMovieVector3;
413
- }): number =>
414
- (e.max.x - e.min.x) * (e.max.y - e.min.y) * (e.max.z - e.min.z);
415
- const share: number = volume(front) / (volume(front) + volume(rear));
416
- box(b("Foot"), 0.0145 * (1 - share), rear.min, rear.max);
417
- box(
418
- b("Toes"),
419
- 0.0145 * share,
420
- front.min,
421
- front.max,
422
- at(b("HalluxProximal")),
423
- );
424
- }
425
148
 
426
149
  const parentOf: Partial<
427
150
  Record<AutoMovieHumanoidBone, AutoMovieHumanoidBone>
@@ -430,21 +153,15 @@ export namespace AutoMovieHumanCanonicalProfile {
430
153
  chest: "spine",
431
154
  neck: "chest",
432
155
  head: "neck",
433
- leftUpperArm: "chest",
434
- rightUpperArm: "chest",
435
- leftLowerArm: "leftUpperArm",
436
- rightLowerArm: "rightUpperArm",
437
- leftHand: "leftLowerArm",
438
- rightHand: "rightLowerArm",
439
- leftUpperLeg: "hips",
440
- rightUpperLeg: "hips",
441
- leftLowerLeg: "leftUpperLeg",
442
- rightLowerLeg: "rightUpperLeg",
443
- leftFoot: "leftLowerLeg",
444
- rightFoot: "rightLowerLeg",
445
- leftToes: "leftFoot",
446
- rightToes: "rightFoot",
447
156
  };
157
+ // Each group of rig bones shares one Dempster share by collider volume.
158
+ const groups: { share: number; bones: AutoMovieHumanoidBone[] }[] = [
159
+ { share: 0.142, bones: ["hips"] },
160
+ { share: 0.139, bones: ["spine"] },
161
+ { share: 0.216, bones: ["chest"] },
162
+ { share: 0.081 - 0.0694, bones: ["neck"] },
163
+ { share: 0.0694, bones: ["head"] },
164
+ ];
448
165
  const hands: AutoMovieHumanoidBone[][] = [];
449
166
  for (const side of ["left", "right"] as const) {
450
167
  const b = (name: string): AutoMovieHumanoidBone =>
@@ -452,11 +169,77 @@ export namespace AutoMovieHumanCanonicalProfile {
452
169
  const hand: AutoMovieHumanoidBone[] = [b("Hand")];
453
170
  for (const chain of DIGITS)
454
171
  chain.forEach((name: string, i: number): void => {
172
+ const joint: IJoint = j(b(name));
173
+ const next: string | undefined = chain[i + 1];
174
+ capsule(
175
+ b(name),
176
+ joint.position,
177
+ next === undefined ? (joint.tip ?? joint.position) : at(b(next)),
178
+ joint.radius,
179
+ next === undefined && joint.tip !== null,
180
+ );
455
181
  parentOf[b(name)] = i === 0 ? b("Hand") : b(chain[i - 1]!);
456
182
  hand.push(b(name));
457
183
  });
458
184
  hands.push(hand);
185
+ parentOf[b("UpperArm")] = "chest";
186
+ parentOf[b("LowerArm")] = b("UpperArm");
187
+ parentOf[b("Hand")] = b("LowerArm");
188
+ parentOf[b("UpperLeg")] = "hips";
189
+ parentOf[b("LowerLeg")] = b("UpperLeg");
190
+ parentOf[b("Foot")] = b("LowerLeg");
191
+ parentOf[b("Toes")] = b("Foot");
192
+ groups.push(
193
+ { share: 0.028, bones: [b("UpperArm")] },
194
+ { share: 0.016, bones: [b("LowerArm")] },
195
+ { share: 0.006, bones: hand },
196
+ { share: 0.1, bones: [b("UpperLeg")] },
197
+ { share: 0.0465, bones: [b("LowerLeg")] },
198
+ { share: 0.0145, bones: [b("Foot"), b("Toes")] },
199
+ );
459
200
  }
201
+
202
+ const segments: P.ISegment[] = [];
203
+ for (const group of groups) {
204
+ const members: IPart[][] = group.bones.map(
205
+ (bone: AutoMovieHumanoidBone): IPart[] => {
206
+ const found: IPart[] | undefined = parts.get(bone);
207
+ if (found === undefined)
208
+ throw new Error(`The polygon profile has no collider on ${bone}`);
209
+ return found;
210
+ },
211
+ );
212
+ const density: number =
213
+ (group.share * mass) /
214
+ members
215
+ .flat()
216
+ .reduce((sum: number, part: IPart): number => sum + part.volume, 0);
217
+ group.bones.forEach(
218
+ (bone: AutoMovieHumanoidBone, index: number): void => {
219
+ const whole: combinePhysicalMassProperties.IPart =
220
+ combinePhysicalMassProperties(
221
+ members[index]!.map(
222
+ (part: IPart): combinePhysicalMassProperties.IPart => ({
223
+ mass: density * part.volume,
224
+ centerOfMass: part.shape.transform.position,
225
+ inertia: Vector3.scale(part.inertia, density * part.volume),
226
+ inertiaRotation: part.inertiaRotation,
227
+ }),
228
+ ),
229
+ );
230
+ segments.push({
231
+ bone,
232
+ neutral: { position: origin(bone), rotation: identity },
233
+ mass: whole.mass,
234
+ centerOfMass: whole.centerOfMass,
235
+ inertia: whole.inertia,
236
+ inertiaRotation: whole.inertiaRotation,
237
+ shapes: members[index]!.map((part: IPart): P.IShape => part.shape),
238
+ });
239
+ },
240
+ );
241
+ }
242
+
460
243
  const children = (bone: AutoMovieHumanoidBone): AutoMovieHumanoidBone[] =>
461
244
  (Object.keys(parentOf) as AutoMovieHumanoidBone[]).filter(
462
245
  (c: AutoMovieHumanoidBone): boolean => parentOf[c] === bone,
@@ -467,9 +250,6 @@ export namespace AutoMovieHumanCanonicalProfile {
467
250
  (sum: number, c: AutoMovieHumanoidBone): number => sum + downstream(c),
468
251
  0,
469
252
  );
470
- const origin = (bone: AutoMovieHumanoidBone): IAutoMovieVector3 =>
471
- segments.find((s: P.ISegment): boolean => s.bone === bone)!.neutral
472
- .position;
473
253
  const links: P.IJoint[] = (
474
254
  Object.keys(parentOf) as AutoMovieHumanoidBone[]
475
255
  ).map((child: AutoMovieHumanoidBone): P.IJoint => {
@@ -545,11 +325,26 @@ export namespace AutoMovieHumanCanonicalProfile {
545
325
  },
546
326
  ],
547
327
  provenance:
548
- "Polygon-man contact profile: drawn primitives, Dempster segment masses (Winter table 4.1), uniform-solid collider inertia.",
328
+ "Polygon-man contact profile: convex hulls of the drawn ring points with capsule phalanges, Dempster segment masses (Winter table 4.1), uniform-solid collider inertia.",
549
329
  };
550
330
  }
551
331
  }
552
332
 
333
+ /** One collider of a segment with the uniform solid's properties about its own centre. */
334
+ interface IPart {
335
+ /** The collider, its transform in the segment's frame. */
336
+ shape: P.IShape;
337
+
338
+ /** Volume, cubic metres. */
339
+ volume: number;
340
+
341
+ /** Principal moments per unit mass, square metres. */
342
+ inertia: IAutoMovieVector3;
343
+
344
+ /** Rotation from the principal frame to the segment's frame. */
345
+ inertiaRotation: IAutoMovieQuaternion;
346
+ }
347
+
553
348
  /** The four fingers, by rig name. */
554
349
  const FINGERS: readonly string[] = ["Index", "Middle", "Ring", "Little"];
555
350