Ejemplo n.º 1
0
Matrix makeMatrixAxisAngle(const Vector axis, const float angle) {
	
	float length = vLength(axis);
	if(length < 0.0005){

		return makeMatrixIdentity();
	}

	// Normalizing, but reusing the length.
	Vector axisN = vsDiv(axis, length);

	float Sin = sin(-angle);
	float Cos = cos(-angle);

	Matrix matrix = makeMatrixIdentity();
	matrix.values[0][0] = Cos + axisN.x*axisN.x*(1-Cos);
	matrix.values[1][0] = axisN.x*axisN.y*(1-Cos) - axisN.z*Sin;
	matrix.values[2][0] = axisN.y*Sin + axisN.x*axisN.z*(1-Cos);
	matrix.values[0][1] = axisN.z*Sin + axisN.x*axisN.y*(1-Cos);
	matrix.values[1][1] = Cos + axisN.y*axisN.y*(1-Cos);
	matrix.values[2][1] = -axisN.x*Sin + axisN.y*axisN.z*(1-Cos);
	matrix.values[0][2] = -axisN.y*Sin + axisN.x*axisN.z*(1-Cos);
	matrix.values[1][2] = axisN.x*Sin + axisN.y*axisN.z*(1-Cos);
	matrix.values[2][2] = Cos + axisN.z*axisN.z*(1-Cos);

	return matrix;
}
Ejemplo n.º 2
0
Scene makeScene () {

	return (Scene) {makeSceneObjectPointerContainer(1000), makeMaterialPointerContainer(10), makePhotonEndPointContainer(1000), makeMatrixIdentity(), makeColor(0.5, 0.7, 1), 0.8};
}