Example #1
0
/**
 * @ingroup experimental
 * @brief this is an opinionated method (opinionated about what axis is yaw, pitch, roll and what is left/right/up/down
 *
 * @param self the quaternion
 * @param ax the x axis
 * @param ay the y axis
 * @param az the z axis
 *
 */
HYPAPI quaternion * quaternion_set_from_euler_anglesf3_EXP(quaternion *self, float ax, float ay, float az)
{
	vector3 vx;
	vector3 vy;
	vector3 vz;
	quaternion qx;
	quaternion qy;
	quaternion qz;
	
	vector3_setf3(&vx, 1, 0, 0);
	vector3_setf3(&vy, 0, 1, 0);
	vector3_setf3(&vz, 0, 0, 1);
	
	quaternion_set_from_axis_anglev3(&qx, &vx, ax);
	quaternion_set_from_axis_anglev3(&qy, &vy, ay);
	quaternion_set_from_axis_anglev3(&qz, &vz, az);
	
	/* self = qx * qy * qz */
	quaternion_multiply(&qx, &qy);
	quaternion_multiply(&qx, &qz);	
	quaternion_set(self, &qx);
	
	quaternion_normalize(self);
	
	return self;
}
Example #2
0
static char *test_vector3_cross_product(void)
{
	struct vector3 a;
	struct vector3 b;
	struct vector3 r;

	vector3_setf3(&a, 3.0f, -3.0f, 1.0f);
	vector3_setf3(&b, 4.0f, 9.0f, 2.0f);

	vector3_cross_product(&r, &a, &b);

	test_assert(scalar_equalsf(r.x, -15.0f));
	test_assert(scalar_equalsf(r.y, -2.0f));
	test_assert(scalar_equalsf(r.z, 39.0f));

	/* tests lack of commutative property */
	vector3_cross_product(&r, &b, &a);

	test_assert(!scalar_equalsf(r.x, -15.0f));
	test_assert(!scalar_equalsf(r.y, -2.0f));
	test_assert(!scalar_equalsf(r.z, 39.0f));

	return 0;
}
Example #3
0
/** 
 * @ingroup vector3
 * @brief initializes the vertex with zeros
 */
HYPAPI vector3 * vector3_zero(vector3 *self)
{
	return vector3_setf3(self, 0, 0, 0);
}