From d9ccdfed9fba93fb3e1685b5dcc1ec21e0d19e58 Mon Sep 17 00:00:00 2001
From: Amorilia <amorilia@users.sourceforge.net>
Date: Mon, 12 Dec 2005 03:12:03 +0000
Subject: [PATCH] Removed BoneToMatrix44 helper functions. (They will be
 implemented in Python in the Blender exporter.)

---
 nif_math.cpp | 76 ----------------------------------------------------
 nif_math.h   |  5 ----
 niflib.h     |  3 ---
 3 files changed, 84 deletions(-)

diff --git a/nif_math.cpp b/nif_math.cpp
index 0286a129..99a177ad 100644
--- a/nif_math.cpp
+++ b/nif_math.cpp
@@ -298,79 +298,3 @@ void QuatToEuler( Quaternion const & quat, ostream & out ) {
 		<< "         Bank:  " << b << endl;
 	
 }
-
-float Length(Vector3 const & a) {
-	return sqrt(a.x*a.x + a.y*a.y + a.z*a.z);
-}
-
-Vector3 Normalize(Vector3 const & a) {
-	float l = Length(a);
-	return Vector3(a.x/l, a.y/l, a.z/l);
-}
-
-float DotProduct(Vector3 const & a, Vector3 const & b) {
-	return a.x*b.x + a.y*b.y + a.z*b.z;
-}
-
-Vector3 CrossProduct(Vector3 const & a, Vector3 const & b) {
-	return Vector3(a.y * b.z - a.z * b.y, a.z * b.x - a.x * b.z, a.x * b.y - a.y * b.x);
-}
-
-float Angle(Vector3 const & a, Vector3 const & b) {
-	float pi = 3.141592653589793f;
-	float s = Length(a) * Length(b);
-	float f = DotProduct(a, b) / s;
-	if (f >=  1.0f) return 0.0f;
-	if (f <= -1.0f) return pi / 2.0f;
-	return atan(-f / sqrt(1.0f - f * f)) + pi / 2.0f;
-}
-
-Matrix44 RotateMatrix44( Vector3 const & axis, float angle) {
-	float vx = axis.x;
-	float vy = axis.y;
-	float vz = axis.z;
-	float vx2 = vx * vx;
-	float vy2 = vy * vy;
-	float vz2 = vz * vz;
-	float cs = cos(angle);
-	float sn = sin(angle);
-	float co1 = 1.0f - cs;
-	return Matrix44(
-		vx2 * co1 + cs,	vx * vy * co1 + vz * sn,	vz * vx * co1 - vy * sn,	0.0f,
-		vx * vy * co1 - vz * sn,	vy2 * co1 + cs,	vy * vz * co1 + vx * sn,	0.0f,
-		vz * vx * co1 + vy * sn,	vy * vz * co1 - vx * sn,	vz2 * co1 + cs,	0.0f,
-		0.0f,	0.0f,	0.0f,	1.0f);
-}
-
-Matrix44 BoneToMatrix44( Vector3 const & bone_head, Vector3 const & bone_tail, float roll, float parent_len ) {
-	float theta;
-	Vector3 bone_vec;
-	bone_vec.x = bone_tail.x - bone_head.x;
-	bone_vec.y = bone_tail.y - bone_head.y;
-	bone_vec.z = bone_tail.z - bone_head.z;
-	Matrix44 bMatrix, rMatrix, result;
-
-	Vector3 target(1.0f, 0.0f, 0.0f); // X-aligned
-	Vector3 nor = Normalize(bone_vec);
-	Vector3 axis = CrossProduct(target, nor);
-	if (DotProduct(axis, axis) > 0.0000000000001) {
-		axis = Normalize(axis);
-		theta = acos(DotProduct(target, nor));
-		bMatrix = RotateMatrix44(axis, theta);
-	} else {
-		float updown;
-		if (DotProduct(target, nor) > 0.0f) updown =  1.0f;
-		else updown = -1.0f;
-		bMatrix = Matrix44(
-			updown, 0.0f, 0.0f, 0.0f,
-			0.0f, updown, 0.0f, 0.0f,
-			0.0f, 0.0f, 1.0f, 0.0f,
-			0.0f, 0.0f, 0.0f, 1.0f);
-	};
-	rMatrix = RotateMatrix44(nor, roll);
-	result = MultMatrix44(bMatrix, rMatrix);
-	result[3][0] = bone_head.x + parent_len; // X-aligned
-	result[3][1] = bone_head.y;
-	result[3][2] = bone_head.z;
-	return result;
-}
diff --git a/nif_math.h b/nif_math.h
index e2753f19..8d30a887 100644
--- a/nif_math.h
+++ b/nif_math.h
@@ -58,10 +58,5 @@ void SetIdentity44( Matrix44 & m );
 void PrintMatrix33( Matrix33 const & m, ostream & out );
 void PrintMatrix44( Matrix44 const & m, ostream & out );
 Quaternion MatrixToQuat( Matrix33 const & m );
-Vector3 Normalize(Vector3 const & a);
-float DotProduct(Vector3 const & a, Vector3 const & b);
-Vector3 CrossProduct(Vector3 const & a, Vector3 const & b); // = MultVector3
-float Angle(Vector3 const & a, Vector3 const & b);
-Matrix44 BoneToMatrix44( Vector3 const & bone_head, Vector3 const & bone_tail, float roll, float parent_len );
 
 #endif
diff --git a/niflib.h b/niflib.h
index d56518ca..d930335a 100644
--- a/niflib.h
+++ b/niflib.h
@@ -425,9 +425,6 @@ struct Matrix44 {
     }
 };
 
-// Bone calculation helper function from the nif_math module.
-Matrix44 BoneToMatrix44( Vector3 const & bone_head, Vector3 const & bone_tail, float roll, float parent_len );
-
 struct Color {
 	float r, g, b, a;
 	Color() {}
-- 
GitLab