Esempio n. 1
0
void V_uxUyFromUz(Vector u_z, Vector *u_x, Vector *u_y) {

	// If u_z and (0, 1, 0) are colinear...
	if ((u_z.x == 0) && (u_z.z == 0)) {
		// *u_x.z = u_z.y in order for the basis to be orthonormal and direct
		*u_x = V_new(0, 0, u_z.y);
		// What comes naturally!
		*u_y = V_new(u_z.y, 0, 0);
	}
	else{
		double length = V_length(u_z);
		// Using cross product to get u_x orthogonal to ((0, 1, 0), u_z)
		*u_x = V_multiply(length, V_unit(V_cross(V_new(0,1,0), u_z)));
		// (u_x, u_y, u_z) must be direct, therefore u_y = u_z^u_x
		*u_y = V_multiply(length, V_unit(V_cross(u_z, *u_x)));
	}
}
Esempio n. 2
0
void draw_inventory( Player *p, BITMAP *buffer ) {
	Item *it;
	int x, y, q;

	if ( V_length( p->inventory ) == 0 )
		return;

	if ( (it = (Item *)V_get( p->inventory, p->inv_selection )) == NULL )
		return;
	q = IA_read( p->quantity, p->inv_selection );

	x = s_offset_x + (p->cur_image->w / 2);
	y = s_offset_y - ( (it->image->h / 2) + 15 );

	ellipse( buffer, x, y, it->image->w, it->image->h, 56 );
	ellipse( buffer, x, y, it->image->w+1, it->image->h+1, 54 );
	draw_sprite_center( buffer, it->image, x, y );
	if ( q > 1 ) {
		text_mode( -1 );
		textprintf( buffer, font, x+(p->cur_image->w/4), y+(it->image->h/2), GRAY, "%d", q );
		text_mode( 0 );
	}
}
Esempio n. 3
0
double V_decompose(Vector p, Vector u) {

	return V_dot(p, u)*V_length(u);
}
Esempio n. 4
0
Vector V_unit(Vector v){

	return V_multiply(1./V_length(v), v);
}