# CD for ellipsoids

This topic is 3714 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi all. I try to write code using article : Continuous Collision Detection for translating Ellipsoid There is: "Let the triangle be represented by a plane that it lies on {N, d} (N being the planes normal, and d its distance from the origin)..." I have points of triangle and normal, but don't understand how to get d value. Explain me please.

##### Share on other sites
Get vectors to the two corners of the triangle from one other point:v0 = pt1 - pt0;v1 = pt2 - pt0;// Get the normal:n = crossProduct(v1, v0);normalise(n);// Get d:d = -dotProduct(n, pt0);

##### Share on other sites
Something's still wrong. ClsPt determines fine, but ClsPtPl is wrong.
	float d=-n.dot(v1);	float		dispN=disp.dot(n), 		ElCtrDisp=c.dot(n)+d;	//Skip early out test to be able to visualize all data	//if(ElCtrDisp-1>dispN)	//	return false;	//Using article "Appendix A"	float 		k=-2*1/pow((n.Coords[0]*n.Coords[0]*sx*sx+			    n.Coords[1]*n.Coords[1]*sy*sy+			    n.Coords[2]*n.Coords[2]*sz*sz),0.5);	c_Vector3 ClsPt(k*n.Coords[0]*sx*sx/2.0,			k*n.Coords[1]*sy*sy/2.0,			k*n.Coords[2]*sz*sz/2.0);	glPushMatrix();	glTranslatef(c.Coords[0],c.Coords[1],c.Coords[2]);	glScalef(sx,sy,sz);	float amb[4]={0.1,0.1,0.1,1},dif[4]={0,1,0,1};	glEnable(GL_LIGHTING);	glDisable(GL_COLOR_MATERIAL);	glMaterialfv(GL_FRONT_AND_BACK,GL_AMBIENT,amb);	glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE,dif);	glutWireSphere(1,20,20);	glPopMatrix();	amb[0]=1;amb[1]=0;amb[2]=0;amb[3]=1;	dif[0]=0;dif[1]=1;dif[2]=0;dif[3]=1;	glMaterialfv(GL_FRONT_AND_BACK,GL_AMBIENT,amb);	glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE,dif);	glBegin(GL_TRIANGLES);	glNormal3fv(n.Coords);	glVertex3fv(v1.Coords);	glVertex3fv(v2.Coords);	glVertex3fv(v3.Coords);	glEnd();	glDisable(GL_LIGHTING);	glEnable(GL_COLOR_MATERIAL);	glBegin(GL_POINTS);	glVertex3fv((c+ClsPt).Coords);	glVertex3fv(c.Coords);	glEnd();	glBegin(GL_LINES);	glVertex3fv((c+ClsPt).Coords);	glVertex3fv(c.Coords);	glVertex3fv((v1+n).Coords);	glVertex3fv(v1.Coords);	glEnd();	glEnable(GL_LIGHTING);	float		elSep=ClsPt.dot(n)+d,		t=elSep/dispN;	//Skip early out test to be able to visualize all data	//if(t>1)	//	return false;	c_Vector3 ClsPtPl=ClsPt-n*elSep;	glBegin(GL_POINTS);	glVertex3fv((c+ClsPtPl).Coords);	glEnd();	glBegin(GL_LINES);	glVertex3fv((c+ClsPtPl).Coords);	glVertex3fv((c+ClsPt).Coords);	glEnd();	...

Here is image what i got:

1. 1
Rutin
21
2. 2
3. 3
JoeJ
18
4. 4
5. 5

• 13
• 38
• 23
• 13
• 13
• ### Forum Statistics

• Total Topics
631715
• Total Posts
3001868
×