2008-04-01 10:48:44 +00:00
|
|
|
#include "solvespace.h"
|
|
|
|
|
2008-04-18 07:06:37 +00:00
|
|
|
char *Entity::DescriptionString(void) {
|
2008-04-19 11:09:47 +00:00
|
|
|
Request *r = SS.GetRequest(h.request());
|
2008-04-18 07:06:37 +00:00
|
|
|
return r->DescriptionString();
|
|
|
|
}
|
|
|
|
|
2008-04-27 03:26:27 +00:00
|
|
|
void Entity::WorkplaneGetBasisVectors(Vector *u, Vector *v) {
|
2008-04-13 14:28:35 +00:00
|
|
|
double q[4];
|
|
|
|
for(int i = 0; i < 4; i++) {
|
2008-04-27 03:26:27 +00:00
|
|
|
q[i] = SS.GetParam(param[i])->val;
|
2008-04-13 14:28:35 +00:00
|
|
|
}
|
2008-04-18 11:11:48 +00:00
|
|
|
Quaternion quat = Quaternion::MakeFrom(q[0], q[1], q[2], q[3]);
|
2008-04-13 14:28:35 +00:00
|
|
|
|
2008-04-18 11:11:48 +00:00
|
|
|
*u = quat.RotationU();
|
|
|
|
*v = quat.RotationV();
|
2008-04-13 14:28:35 +00:00
|
|
|
}
|
|
|
|
|
2008-04-27 03:26:27 +00:00
|
|
|
Vector Entity::WorkplaneGetNormalVector(void) {
|
2008-04-23 07:29:19 +00:00
|
|
|
Vector u, v;
|
2008-04-27 03:26:27 +00:00
|
|
|
WorkplaneGetBasisVectors(&u, &v);
|
2008-04-23 07:29:19 +00:00
|
|
|
return u.Cross(v);
|
|
|
|
}
|
|
|
|
|
2008-04-27 03:26:27 +00:00
|
|
|
void Entity::WorkplaneGetBasisExprs(ExprVector *u, ExprVector *v) {
|
|
|
|
Expr *a = Expr::FromParam(param[0]);
|
|
|
|
Expr *b = Expr::FromParam(param[1]);
|
|
|
|
Expr *c = Expr::FromParam(param[2]);
|
|
|
|
Expr *d = Expr::FromParam(param[3]);
|
2008-04-20 11:35:10 +00:00
|
|
|
|
|
|
|
Expr *two = Expr::FromConstant(2);
|
|
|
|
|
2008-04-22 13:14:15 +00:00
|
|
|
u->x = a->Square();
|
|
|
|
u->x = (u->x)->Plus(b->Square());
|
|
|
|
u->x = (u->x)->Minus(c->Square());
|
|
|
|
u->x = (u->x)->Minus(d->Square());
|
|
|
|
|
|
|
|
u->y = two->Times(a->Times(d));
|
|
|
|
u->y = (u->y)->Plus(two->Times(b->Times(c)));
|
|
|
|
|
|
|
|
u->z = two->Times(b->Times(d));
|
|
|
|
u->z = (u->z)->Minus(two->Times(a->Times(c)));
|
|
|
|
|
|
|
|
v->x = two->Times(b->Times(c));
|
|
|
|
v->x = (v->x)->Minus(two->Times(a->Times(d)));
|
|
|
|
|
|
|
|
v->y = a->Square();
|
|
|
|
v->y = (v->y)->Minus(b->Square());
|
|
|
|
v->y = (v->y)->Plus(c->Square());
|
|
|
|
v->y = (v->y)->Minus(d->Square());
|
|
|
|
|
|
|
|
v->z = two->Times(a->Times(b));
|
|
|
|
v->z = (v->z)->Plus(two->Times(c->Times(d)));
|
2008-04-20 11:35:10 +00:00
|
|
|
}
|
|
|
|
|
2008-04-27 03:26:27 +00:00
|
|
|
ExprVector Entity::WorkplaneGetOffsetExprs(void) {
|
|
|
|
return SS.GetEntity(point[0])->PointGetExprs();
|
2008-04-23 07:29:19 +00:00
|
|
|
}
|
|
|
|
|
2008-04-21 08:16:38 +00:00
|
|
|
bool Entity::HasPlane(void) {
|
|
|
|
switch(type) {
|
2008-04-27 03:26:27 +00:00
|
|
|
case WORKPLANE:
|
2008-04-21 08:16:38 +00:00
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-04-22 13:14:15 +00:00
|
|
|
void Entity::PlaneGetExprs(ExprVector *n, Expr **dn) {
|
2008-04-27 03:26:27 +00:00
|
|
|
if(type == WORKPLANE) {
|
|
|
|
Expr *a = Expr::FromParam(param[0]);
|
|
|
|
Expr *b = Expr::FromParam(param[1]);
|
|
|
|
Expr *c = Expr::FromParam(param[2]);
|
|
|
|
Expr *d = Expr::FromParam(param[3]);
|
2008-04-22 13:14:15 +00:00
|
|
|
|
|
|
|
Expr *two = Expr::FromConstant(2);
|
|
|
|
|
|
|
|
// Convert the quaternion to our plane's normal vector.
|
|
|
|
n->x = two->Times(a->Times(c));
|
|
|
|
n->x = (n->x)->Plus (two->Times(b->Times(d)));
|
|
|
|
n->y = two->Times(c->Times(d));
|
|
|
|
n->y = (n->y)->Minus(two->Times(a->Times(b)));
|
|
|
|
n->z = a->Square();
|
|
|
|
n->z = (n->z)->Minus(b->Square());
|
|
|
|
n->z = (n->z)->Minus(c->Square());
|
|
|
|
n->z = (n->z)->Plus (d->Square());
|
|
|
|
|
2008-04-27 03:26:27 +00:00
|
|
|
ExprVector p0 = SS.GetEntity(point[0])->PointGetExprs();
|
2008-04-22 13:14:15 +00:00
|
|
|
// The plane is n dot (p - p0) = 0, or
|
|
|
|
// n dot p - n dot p0 = 0
|
|
|
|
// so dn = n dot p0
|
|
|
|
*dn = p0.Dot(*n);
|
|
|
|
} else {
|
|
|
|
oops();
|
|
|
|
}
|
2008-04-21 08:16:38 +00:00
|
|
|
}
|
|
|
|
|
2008-04-19 11:09:47 +00:00
|
|
|
bool Entity::IsPoint(void) {
|
|
|
|
switch(type) {
|
|
|
|
case POINT_IN_3D:
|
2008-04-27 09:03:01 +00:00
|
|
|
// A point by (x, y, z) in our base coordinate system. These
|
|
|
|
// variables are given by param[0:2].
|
2008-04-19 11:09:47 +00:00
|
|
|
case POINT_IN_2D:
|
2008-04-27 09:03:01 +00:00
|
|
|
// A point by (u, v) in a workplane. These variables are given
|
|
|
|
// by param[0:1], and the workplane is given in workplane.
|
|
|
|
case POINT_XFRMD:
|
|
|
|
// A point by a translation of another point. The original
|
|
|
|
// point is given by point[0], and the three offsets in
|
|
|
|
// param[0:2].
|
2008-04-19 11:09:47 +00:00
|
|
|
return true;
|
|
|
|
|
2008-04-22 13:14:15 +00:00
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-04-19 11:44:44 +00:00
|
|
|
bool Entity::PointIsFromReferences(void) {
|
2008-04-21 08:16:38 +00:00
|
|
|
return h.request().IsFromReferences();
|
2008-04-19 11:09:47 +00:00
|
|
|
}
|
|
|
|
|
2008-04-19 11:44:44 +00:00
|
|
|
void Entity::PointForceTo(Vector p) {
|
2008-04-19 11:09:47 +00:00
|
|
|
switch(type) {
|
|
|
|
case POINT_IN_3D:
|
2008-04-27 03:26:27 +00:00
|
|
|
SS.GetParam(param[0])->val = p.x;
|
|
|
|
SS.GetParam(param[1])->val = p.y;
|
|
|
|
SS.GetParam(param[2])->val = p.z;
|
2008-04-19 11:09:47 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case POINT_IN_2D: {
|
2008-04-27 03:26:27 +00:00
|
|
|
Entity *c = SS.GetEntity(workplane);
|
2008-04-19 11:09:47 +00:00
|
|
|
Vector u, v;
|
2008-04-27 03:26:27 +00:00
|
|
|
c->WorkplaneGetBasisVectors(&u, &v);
|
|
|
|
SS.GetParam(param[0])->val = p.Dot(u);
|
|
|
|
SS.GetParam(param[1])->val = p.Dot(v);
|
2008-04-19 11:09:47 +00:00
|
|
|
break;
|
|
|
|
}
|
2008-04-27 09:03:01 +00:00
|
|
|
|
|
|
|
case POINT_XFRMD: {
|
|
|
|
Vector orig = SS.GetEntity(point[0])->PointGetCoords();
|
|
|
|
Vector trans = p.Minus(orig);
|
|
|
|
SS.GetParam(param[0])->val = trans.x;
|
|
|
|
SS.GetParam(param[1])->val = trans.y;
|
|
|
|
SS.GetParam(param[2])->val = trans.z;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2008-04-19 11:09:47 +00:00
|
|
|
default: oops();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-04-19 11:44:44 +00:00
|
|
|
Vector Entity::PointGetCoords(void) {
|
2008-04-19 11:09:47 +00:00
|
|
|
Vector p;
|
|
|
|
switch(type) {
|
|
|
|
case POINT_IN_3D:
|
2008-04-27 03:26:27 +00:00
|
|
|
p.x = SS.GetParam(param[0])->val;
|
|
|
|
p.y = SS.GetParam(param[1])->val;
|
|
|
|
p.z = SS.GetParam(param[2])->val;
|
2008-04-19 11:09:47 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case POINT_IN_2D: {
|
2008-04-27 03:26:27 +00:00
|
|
|
Entity *c = SS.GetEntity(workplane);
|
2008-04-19 11:09:47 +00:00
|
|
|
Vector u, v;
|
2008-04-27 03:26:27 +00:00
|
|
|
c->WorkplaneGetBasisVectors(&u, &v);
|
|
|
|
p = u.ScaledBy(SS.GetParam(param[0])->val);
|
|
|
|
p = p.Plus(v.ScaledBy(SS.GetParam(param[1])->val));
|
2008-04-19 11:09:47 +00:00
|
|
|
break;
|
|
|
|
}
|
2008-04-27 09:03:01 +00:00
|
|
|
|
|
|
|
case POINT_XFRMD: {
|
|
|
|
p = SS.GetEntity(point[0])->PointGetCoords();
|
|
|
|
p.x += SS.GetParam(param[0])->val;
|
|
|
|
p.y += SS.GetParam(param[1])->val;
|
|
|
|
p.z += SS.GetParam(param[2])->val;
|
|
|
|
break;
|
|
|
|
}
|
2008-04-19 11:09:47 +00:00
|
|
|
default: oops();
|
|
|
|
}
|
|
|
|
return p;
|
|
|
|
}
|
|
|
|
|
2008-04-22 13:14:15 +00:00
|
|
|
ExprVector Entity::PointGetExprs(void) {
|
|
|
|
ExprVector r;
|
2008-04-20 11:35:10 +00:00
|
|
|
switch(type) {
|
|
|
|
case POINT_IN_3D:
|
2008-04-27 03:26:27 +00:00
|
|
|
r.x = Expr::FromParam(param[0]);
|
|
|
|
r.y = Expr::FromParam(param[1]);
|
|
|
|
r.z = Expr::FromParam(param[2]);
|
2008-04-20 11:35:10 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case POINT_IN_2D: {
|
2008-04-27 03:26:27 +00:00
|
|
|
Entity *c = SS.GetEntity(workplane);
|
2008-04-22 13:14:15 +00:00
|
|
|
ExprVector u, v;
|
2008-04-27 03:26:27 +00:00
|
|
|
c->WorkplaneGetBasisExprs(&u, &v);
|
2008-04-20 11:35:10 +00:00
|
|
|
|
2008-04-27 03:26:27 +00:00
|
|
|
r = u.ScaledBy(Expr::FromParam(param[0]));
|
|
|
|
r = r.Plus(v.ScaledBy(Expr::FromParam(param[1])));
|
2008-04-20 11:35:10 +00:00
|
|
|
break;
|
|
|
|
}
|
2008-04-27 09:03:01 +00:00
|
|
|
case POINT_XFRMD: {
|
|
|
|
ExprVector orig = SS.GetEntity(point[0])->PointGetExprs();
|
|
|
|
ExprVector trans;
|
|
|
|
trans.x = Expr::FromParam(param[0]);
|
|
|
|
trans.y = Expr::FromParam(param[1]);
|
|
|
|
trans.z = Expr::FromParam(param[2]);
|
|
|
|
r = orig.Plus(trans);
|
|
|
|
break;
|
|
|
|
}
|
2008-04-20 11:35:10 +00:00
|
|
|
default: oops();
|
|
|
|
}
|
2008-04-22 13:14:15 +00:00
|
|
|
return r;
|
2008-04-20 11:35:10 +00:00
|
|
|
}
|
|
|
|
|
2008-04-27 05:00:12 +00:00
|
|
|
void Entity::PointGetExprsInWorkplane(hEntity wrkpl, Expr **u, Expr **v) {
|
|
|
|
if(type == POINT_IN_2D && workplane.v == wrkpl.v) {
|
|
|
|
// They want our coordinates in the form that we've written them,
|
|
|
|
// very nice.
|
|
|
|
*u = Expr::FromParam(param[0]);
|
|
|
|
*v = Expr::FromParam(param[1]);
|
|
|
|
} else {
|
|
|
|
// Get the offset and basis vectors for this weird exotic csys.
|
|
|
|
Entity *w = SS.GetEntity(wrkpl);
|
|
|
|
ExprVector wp = w->WorkplaneGetOffsetExprs();
|
|
|
|
ExprVector wu, wv;
|
|
|
|
w->WorkplaneGetBasisExprs(&wu, &wv);
|
|
|
|
|
|
|
|
// Get our coordinates in three-space, and project them into that
|
|
|
|
// coordinate system.
|
|
|
|
ExprVector ev = PointGetExprs();
|
|
|
|
ev = ev.Minus(wp);
|
|
|
|
*u = ev.Dot(wu);
|
|
|
|
*v = ev.Dot(wv);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-04-12 14:12:26 +00:00
|
|
|
void Entity::LineDrawOrGetDistance(Vector a, Vector b) {
|
|
|
|
if(dogd.drawing) {
|
|
|
|
glBegin(GL_LINE_STRIP);
|
|
|
|
glxVertex3v(a);
|
|
|
|
glxVertex3v(b);
|
|
|
|
glEnd();
|
|
|
|
} else {
|
|
|
|
Point2d ap = SS.GW.ProjectPoint(a);
|
|
|
|
Point2d bp = SS.GW.ProjectPoint(b);
|
|
|
|
|
|
|
|
double d = dogd.mp.DistanceToLine(ap, bp.Minus(ap), true);
|
|
|
|
dogd.dmin = min(dogd.dmin, d);
|
|
|
|
}
|
2008-04-11 11:13:47 +00:00
|
|
|
}
|
|
|
|
|
2008-04-25 07:04:09 +00:00
|
|
|
void Entity::LineDrawOrGetDistanceOrEdge(Vector a, Vector b) {
|
|
|
|
LineDrawOrGetDistance(a, b);
|
|
|
|
if(dogd.edges) {
|
|
|
|
SEdge edge;
|
|
|
|
edge.a = a; edge.b = b;
|
|
|
|
dogd.edges->l.Add(&edge);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-04-22 10:53:42 +00:00
|
|
|
void Entity::Draw(int order) {
|
2008-04-12 14:12:26 +00:00
|
|
|
dogd.drawing = true;
|
2008-04-25 07:04:09 +00:00
|
|
|
dogd.edges = NULL;
|
2008-04-22 10:53:42 +00:00
|
|
|
DrawOrGetDistance(order);
|
2008-04-12 14:12:26 +00:00
|
|
|
}
|
|
|
|
|
2008-04-25 07:04:09 +00:00
|
|
|
void Entity::GenerateEdges(SEdgeList *el) {
|
|
|
|
dogd.drawing = false;
|
|
|
|
dogd.edges = el;
|
|
|
|
DrawOrGetDistance(-1);
|
|
|
|
dogd.edges = NULL;
|
|
|
|
}
|
|
|
|
|
2008-04-12 14:12:26 +00:00
|
|
|
double Entity::GetDistance(Point2d mp) {
|
|
|
|
dogd.drawing = false;
|
2008-04-25 07:04:09 +00:00
|
|
|
dogd.edges = NULL;
|
2008-04-12 14:12:26 +00:00
|
|
|
dogd.mp = mp;
|
|
|
|
dogd.dmin = 1e12;
|
|
|
|
|
2008-04-22 10:53:42 +00:00
|
|
|
DrawOrGetDistance(-1);
|
2008-04-12 14:12:26 +00:00
|
|
|
|
|
|
|
return dogd.dmin;
|
|
|
|
}
|
|
|
|
|
2008-04-22 10:53:42 +00:00
|
|
|
void Entity::DrawOrGetDistance(int order) {
|
2008-04-28 07:18:39 +00:00
|
|
|
Group *g = SS.GetGroup(group);
|
|
|
|
// If an entity is invisible, then it doesn't get shown, and it doesn't
|
|
|
|
// contribute a distance for the selection, but it still generates edges.
|
|
|
|
if(!(g->visible) && !dogd.edges) return;
|
|
|
|
|
2008-04-25 07:04:09 +00:00
|
|
|
glxColor3d(1, 1, 1);
|
2008-04-19 11:09:47 +00:00
|
|
|
|
2008-04-09 08:39:01 +00:00
|
|
|
switch(type) {
|
2008-04-27 09:03:01 +00:00
|
|
|
case POINT_XFRMD:
|
2008-04-19 11:09:47 +00:00
|
|
|
case POINT_IN_3D:
|
|
|
|
case POINT_IN_2D: {
|
2008-04-22 10:53:42 +00:00
|
|
|
if(order >= 0 && order != 2) break;
|
2008-04-21 08:16:38 +00:00
|
|
|
if(!SS.GW.showPoints) break;
|
|
|
|
|
2008-04-27 09:03:01 +00:00
|
|
|
if(h.isFromRequest()) {
|
|
|
|
Entity *isfor = SS.GetEntity(h.request().entity(0));
|
|
|
|
if(!SS.GW.showWorkplanes && isfor->type == Entity::WORKPLANE) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2008-04-19 11:09:47 +00:00
|
|
|
|
2008-04-19 11:44:44 +00:00
|
|
|
Vector v = PointGetCoords();
|
2008-04-19 11:09:47 +00:00
|
|
|
|
|
|
|
if(dogd.drawing) {
|
2008-04-22 10:53:42 +00:00
|
|
|
double s = 3;
|
2008-04-19 11:09:47 +00:00
|
|
|
Vector r = SS.GW.projRight.ScaledBy(s/SS.GW.scale);
|
|
|
|
Vector d = SS.GW.projUp.ScaledBy(s/SS.GW.scale);
|
|
|
|
|
2008-04-25 07:04:09 +00:00
|
|
|
glxColor3d(0, 0.8, 0);
|
2008-04-19 11:09:47 +00:00
|
|
|
glBegin(GL_QUADS);
|
|
|
|
glxVertex3v(v.Plus (r).Plus (d));
|
|
|
|
glxVertex3v(v.Plus (r).Minus(d));
|
|
|
|
glxVertex3v(v.Minus(r).Minus(d));
|
|
|
|
glxVertex3v(v.Minus(r).Plus (d));
|
|
|
|
glEnd();
|
|
|
|
} else {
|
|
|
|
Point2d pp = SS.GW.ProjectPoint(v);
|
2008-04-27 05:00:12 +00:00
|
|
|
// Make a free point slightly easier to select, so that with
|
|
|
|
// coincident points, we select the free one.
|
2008-05-01 06:25:38 +00:00
|
|
|
dogd.dmin = pp.DistanceTo(dogd.mp) - 4;
|
2008-04-19 11:09:47 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2008-04-27 03:26:27 +00:00
|
|
|
case WORKPLANE: {
|
2008-04-22 10:53:42 +00:00
|
|
|
if(order >= 0 && order != 0) break;
|
2008-04-27 03:26:27 +00:00
|
|
|
if(!SS.GW.showWorkplanes) break;
|
2008-04-19 11:09:47 +00:00
|
|
|
|
2008-04-09 08:39:01 +00:00
|
|
|
Vector p;
|
2008-04-27 03:26:27 +00:00
|
|
|
p = SS.GetEntity(point[0])->PointGetCoords();
|
2008-04-01 10:48:44 +00:00
|
|
|
|
2008-04-13 14:28:35 +00:00
|
|
|
Vector u, v;
|
2008-04-27 03:26:27 +00:00
|
|
|
WorkplaneGetBasisVectors(&u, &v);
|
2008-04-01 10:48:44 +00:00
|
|
|
|
2008-04-13 10:57:41 +00:00
|
|
|
double s = (min(SS.GW.width, SS.GW.height))*0.4/SS.GW.scale;
|
2008-04-01 10:48:44 +00:00
|
|
|
|
2008-04-13 10:57:41 +00:00
|
|
|
Vector us = u.ScaledBy(s);
|
|
|
|
Vector vs = v.ScaledBy(s);
|
|
|
|
|
|
|
|
Vector pp = p.Plus (us).Plus (vs);
|
|
|
|
Vector pm = p.Plus (us).Minus(vs);
|
|
|
|
Vector mm = p.Minus(us).Minus(vs);
|
|
|
|
Vector mp = p.Minus(us).Plus (vs);
|
2008-04-11 11:13:47 +00:00
|
|
|
|
2008-04-25 07:04:09 +00:00
|
|
|
glxColor3d(0, 0.4, 0.4);
|
2008-04-12 14:12:26 +00:00
|
|
|
LineDrawOrGetDistance(pp, pm);
|
|
|
|
LineDrawOrGetDistance(pm, mm);
|
|
|
|
LineDrawOrGetDistance(mm, mp);
|
|
|
|
LineDrawOrGetDistance(mp, pp);
|
2008-04-01 10:48:44 +00:00
|
|
|
|
2008-04-12 14:12:26 +00:00
|
|
|
if(dogd.drawing) {
|
|
|
|
glPushMatrix();
|
|
|
|
glxTranslatev(mm);
|
2008-04-27 03:26:27 +00:00
|
|
|
glxOntoWorkplane(u, v);
|
2008-04-19 11:09:47 +00:00
|
|
|
glxWriteText(DescriptionString());
|
2008-04-12 14:12:26 +00:00
|
|
|
glPopMatrix();
|
|
|
|
}
|
2008-04-09 08:39:01 +00:00
|
|
|
break;
|
|
|
|
}
|
2008-04-13 10:57:41 +00:00
|
|
|
|
|
|
|
case LINE_SEGMENT: {
|
2008-04-22 10:53:42 +00:00
|
|
|
if(order >= 0 && order != 1) break;
|
2008-04-27 03:26:27 +00:00
|
|
|
Vector a = SS.GetEntity(point[0])->PointGetCoords();
|
|
|
|
Vector b = SS.GetEntity(point[1])->PointGetCoords();
|
2008-04-25 07:04:09 +00:00
|
|
|
LineDrawOrGetDistanceOrEdge(a, b);
|
2008-04-13 10:57:41 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2008-04-25 12:07:17 +00:00
|
|
|
case CUBIC: {
|
2008-04-27 03:26:27 +00:00
|
|
|
Vector p0 = SS.GetEntity(point[0])->PointGetCoords();
|
|
|
|
Vector p1 = SS.GetEntity(point[1])->PointGetCoords();
|
|
|
|
Vector p2 = SS.GetEntity(point[2])->PointGetCoords();
|
|
|
|
Vector p3 = SS.GetEntity(point[3])->PointGetCoords();
|
2008-04-25 12:07:17 +00:00
|
|
|
int i, n = 20;
|
|
|
|
Vector prev = p0;
|
|
|
|
for(i = 1; i <= n; i++) {
|
|
|
|
double t = ((double)i)/n;
|
|
|
|
Vector p =
|
|
|
|
(p0.ScaledBy((1 - t)*(1 - t)*(1 - t))).Plus(
|
|
|
|
(p1.ScaledBy(3*t*(1 - t)*(1 - t))).Plus(
|
|
|
|
(p2.ScaledBy(3*t*t*(1 - t))).Plus(
|
|
|
|
(p3.ScaledBy(t*t*t)))));
|
|
|
|
LineDrawOrGetDistanceOrEdge(prev, p);
|
|
|
|
prev = p;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2008-04-09 08:39:01 +00:00
|
|
|
default:
|
|
|
|
oops();
|
2008-04-01 10:48:44 +00:00
|
|
|
}
|
|
|
|
}
|
2008-04-12 15:17:58 +00:00
|
|
|
|