[Bf-committers] Building matrices from loc, size, quat

Ton Roosendaal bf-committers@blender.org
Sat, 31 Jul 2004 11:27:22 +0200


Hi,

Yah my typical reaction also is 'dont use matrices unless it's for  
display purposes'. But the question remains valid of course.

In the blenlib/intern/arithb.c file you can find all of Blender's math  
formulas. I've quickly assembled a sample for you, but it's untested...

(btw; arithb Mul and Cpy functions go from right to left, like strcpy)

void quat_size_vec_to_mat4(float *quat, float *size, float *vec, float  
mat4[4][4])
{
	float mat3q[3][3], mat3s[3][3]. mat3[3][3];

	QuatToMat3(quat, mat3q);
	SizeToMat3(quat, mat3s);
	Mat3MulMat3(mat3, mat3q, mat3s); // first scale, then rotate
	Mat4CpyMat3(mat4, mat3);
	VECCOPY(mat4[3], vec);
}

-Ton-


On Friday, Jul 30, 2004, at 15:23 Europe/Amsterdam, Roland Hess wrote:

> I'm working on the character animation tools, and I need to build a  
> transform matrix for a bone. I have the loc, size and quat values, and  
> I'd like to put them into a 4x4 matrix for easy use later on. The way  
> to do this is most likely in the code somewhere already, but I can't  
> find. If someone could either point me to the maths on how to do this,  
> or to the already existing code, it'll save me a pile of time.
> --  
> Roland Hess - harkyman
> Digital Prepress/Network Administrator
> Reed & Witting Company
> _______________________________________________
> Bf-committers mailing list
> Bf-committers@blender.org
> http://www.blender.org/mailman/listinfo/bf-committers
>
>
------------------------------------------------------------------------ 
--
Ton Roosendaal  Blender Foundation ton@blender.org  
http://www.blender.org