Skip to content

Commit 99c90b9

Browse files
author
dhsu
committed
updated subsys
1 parent 61850d2 commit 99c90b9

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ fn holistic(data: Vec<Vec<[f32; 3]>>) -> PyResult<Vec<Vec<[f32; 4]>>> {
8888
// hand result
8989
let hand_result_l = _hand(hand_data_l);
9090
let hand_result_r = _hand(hand_data_r);
91-
91+
9292
// face result
9393
let mut face_result = vec![[f32::NAN, f32::NAN, f32::NAN, f32::NAN]; 4];
9494
if face_data.len() == 468 {
@@ -97,7 +97,7 @@ fn holistic(data: Vec<Vec<[f32; 3]>>) -> PyResult<Vec<Vec<[f32; 4]>>> {
9797
face_result[i] = face_rotations[i].to_array();
9898
}
9999
}
100-
100+
101101
// pose result
102102
let mut pose_result = vec![[f32::NAN, f32::NAN, f32::NAN, f32::NAN]; 36];
103103
if pose_data.len() == 33 {

src/pose.rs

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
extern crate cgt_math;
2-
use cgt_math::{Plane, Quaternion, Vector3};
2+
use cgt_math::{Plane, Quaternion, Vector3, Axis};
33

44
/// Calculates limb fk chain, hip, shoulder and face rotation.
55
/// May uses hip center as pivot.
@@ -57,9 +57,10 @@ fn torso_rotation(data: &[Vector3; 36], rotation_data: &mut [Quaternion; 36]) {
5757
fn shoulder_rotation(data: &[Vector3; 36], rotation_data: &mut [Quaternion; 36]) {
5858
// As the torso rotation usually is used to rotate the rig,
5959
// the torso rotation got to be substracted from the hip rotation
60-
let shoulder_rot =
61-
Quaternion::from_vec_to_track_quat((data[12] - data[34]).normalize().neg(), 2, 1); // rotation from center to right shoulder
62-
let hip_rot = Quaternion::from_vec_to_track_quat((data[24] - data[33]).normalize().neg(), 2, 1); // rotation from center to right hip
60+
let shoulder_rot = Quaternion::rotate_towards((data[12]-data[34]).normalize(), Axis::Z, Axis::Y);
61+
// Quaternion::from_vec_to_track_quat((data[12] - data[34]).normalize().neg(), 2, 1); // rotation from center to right shoulder
62+
let hip_rot = Quaternion::rotate_towards((data[24] - data[33]).normalize(), Axis::Z, Axis::Y); // rotation from center to right hip
63+
// let hip_rot = Quaternion::from_vec_to_track_quat((data[24] - data[33]).normalize().neg(), 2, 1); // rotation from center to right hip
6364
rotation_data[34] = shoulder_rot - hip_rot;
6465
}
6566

@@ -68,7 +69,8 @@ fn calc_limb_chain_rotations(data: &[Vector3; 4]) -> [Quaternion; 3] {
6869
let mut arr: [Quaternion; 3] = [Quaternion::IDENTITY; 3];
6970
for i in 1..4 {
7071
arr[i - 1] =
71-
Quaternion::from_vec_to_track_quat((data[i - 1] - data[i]).normalize().neg(), 4, 2);
72+
Quaternion::rotate_towards((data[i-1]-data[i]).normalize().neg(), Axis::X, Axis::Z);
73+
// Quaternion::from_vec_to_track_quat((data[i - 1] - data[i]).normalize().neg(), 4, 2);
7274
}
7375
return arr;
7476
}

0 commit comments

Comments
 (0)