All pastes #746144 Raw Edit

Untitled

public text v1 · immutable
·published 2007-10-22 23:52 UTC
rendered paste body
static void VecClipLine3f(float *v1, float *v2, int axis, float pos)
{
	float vec[3], t;

	vec[0] = v2[0] - v1[0];
	vec[1] = v2[1] - v1[1];
	vec[2] = v2[2] - v1[2];
	
	if (vec[axis] == 0.0f) {
		printf("bad value for VecClipLine3f!\n");
		return;
	}

	t = (pos-v1[axis])/vec[axis];
	v2[0] = v1[0] + vec[0]*t;
	v2[1] = v1[1] + vec[1]*t;
	v2[2] = v1[2] + vec[2]*t;
}