Use the vectorized XxxVector::From() functions in a few more

places, to eliminate repetition.

[git-p4: depot-paths = "//depot/solvespace/": change = 1767]
solver
Jonathan Westhues 2008-06-01 19:37:58 -08:00
parent 6748160026
commit 1f70494ce9
1 changed files with 9 additions and 30 deletions

View File

@ -203,10 +203,7 @@ Quaternion Entity::NormalGetNum(void) {
Quaternion q; Quaternion q;
switch(type) { switch(type) {
case NORMAL_IN_3D: case NORMAL_IN_3D:
q.w = SS.GetParam(param[0])->val; q = Quaternion::From(param[0], param[1], param[2], param[3]);
q.vx = SS.GetParam(param[1])->val;
q.vy = SS.GetParam(param[2])->val;
q.vz = SS.GetParam(param[3])->val;
break; break;
case NORMAL_IN_2D: { case NORMAL_IN_2D: {
@ -220,10 +217,7 @@ Quaternion Entity::NormalGetNum(void) {
break; break;
case NORMAL_N_ROT: case NORMAL_N_ROT:
q.w = SS.GetParam(param[0])->val; q = Quaternion::From(param[0], param[1], param[2], param[3]);
q.vx = SS.GetParam(param[1])->val;
q.vy = SS.GetParam(param[2])->val;
q.vz = SS.GetParam(param[3])->val;
q = q.Times(numNormal); q = q.Times(numNormal);
break; break;
@ -410,9 +404,7 @@ Vector Entity::PointGetNum(void) {
Vector p; Vector p;
switch(type) { switch(type) {
case POINT_IN_3D: case POINT_IN_3D:
p.x = SS.GetParam(param[0])->val; p = Vector::From(param[0], param[1], param[2]);
p.y = SS.GetParam(param[1])->val;
p.z = SS.GetParam(param[2])->val;
break; break;
case POINT_IN_2D: { case POINT_IN_2D: {
@ -426,18 +418,13 @@ Vector Entity::PointGetNum(void) {
} }
case POINT_N_TRANS: { case POINT_N_TRANS: {
p = numPoint; Vector trans = Vector::From(param[0], param[1], param[2]);
p.x += timesApplied * SS.GetParam(param[0])->val; p = numPoint.Plus(trans.ScaledBy(timesApplied));
p.y += timesApplied * SS.GetParam(param[1])->val;
p.z += timesApplied * SS.GetParam(param[2])->val;
break; break;
} }
case POINT_N_ROT_TRANS: { case POINT_N_ROT_TRANS: {
Vector offset = Vector::From( Vector offset = Vector::From(param[0], param[1], param[2]);
SS.GetParam(param[0])->val,
SS.GetParam(param[1])->val,
SS.GetParam(param[2])->val);
Quaternion q = PointGetQuaternion(); Quaternion q = PointGetQuaternion();
p = q.Rotate(numPoint); p = q.Rotate(numPoint);
p = p.Plus(offset); p = p.Plus(offset);
@ -445,10 +432,7 @@ Vector Entity::PointGetNum(void) {
} }
case POINT_N_ROT_AA: { case POINT_N_ROT_AA: {
Vector offset = Vector::From( Vector offset = Vector::From(param[0], param[1], param[2]);
SS.GetParam(param[0])->val,
SS.GetParam(param[1])->val,
SS.GetParam(param[2])->val);
Quaternion q = PointGetQuaternion(); Quaternion q = PointGetQuaternion();
p = numPoint.Minus(offset); p = numPoint.Minus(offset);
p = q.Rotate(p); p = q.Rotate(p);
@ -469,9 +453,7 @@ ExprVector Entity::PointGetExprs(void) {
ExprVector r; ExprVector r;
switch(type) { switch(type) {
case POINT_IN_3D: case POINT_IN_3D:
r.x = Expr::From(param[0]); r = ExprVector::From(param[0], param[1], param[2]);
r.y = Expr::From(param[1]);
r.z = Expr::From(param[2]);
break; break;
case POINT_IN_2D: { case POINT_IN_2D: {
@ -565,10 +547,7 @@ Quaternion Entity::PointGetQuaternion(void) {
q.vy = s*SS.GetParam(param[5])->val; q.vy = s*SS.GetParam(param[5])->val;
q.vz = s*SS.GetParam(param[6])->val; q.vz = s*SS.GetParam(param[6])->val;
} else if(type == POINT_N_ROT_TRANS) { } else if(type == POINT_N_ROT_TRANS) {
q.w = SS.GetParam(param[3])->val; q = Quaternion::From(param[3], param[4], param[5], param[6]);
q.vx = SS.GetParam(param[4])->val;
q.vy = SS.GetParam(param[5])->val;
q.vz = SS.GetParam(param[6])->val;
} else oops(); } else oops();
return q; return q;