Trim trailing whitespace.
This commit is contained in:
parent
15446e8f0a
commit
2ecc612801
|
@ -42,7 +42,7 @@ void Example3d(void)
|
||||||
sys.param[sys.params++] = Slvs_MakeParam(6, g, 20.0);
|
sys.param[sys.params++] = Slvs_MakeParam(6, g, 20.0);
|
||||||
sys.entity[sys.entities++] = Slvs_MakePoint3d(102, g, 4, 5, 6);
|
sys.entity[sys.entities++] = Slvs_MakePoint3d(102, g, 4, 5, 6);
|
||||||
// and a line segment connecting them.
|
// and a line segment connecting them.
|
||||||
sys.entity[sys.entities++] = Slvs_MakeLineSegment(200, g,
|
sys.entity[sys.entities++] = Slvs_MakeLineSegment(200, g,
|
||||||
SLVS_FREE_IN_3D, 101, 102);
|
SLVS_FREE_IN_3D, 101, 102);
|
||||||
|
|
||||||
// The distance between the points should be 30.0 units.
|
// The distance between the points should be 30.0 units.
|
||||||
|
@ -117,7 +117,7 @@ void Example2d(void)
|
||||||
sys.entity[sys.entities++] = Slvs_MakePoint2d(302, g, 200, 13, 14);
|
sys.entity[sys.entities++] = Slvs_MakePoint2d(302, g, 200, 13, 14);
|
||||||
|
|
||||||
// And we create a line segment with those endpoints.
|
// And we create a line segment with those endpoints.
|
||||||
sys.entity[sys.entities++] = Slvs_MakeLineSegment(400, g,
|
sys.entity[sys.entities++] = Slvs_MakeLineSegment(400, g,
|
||||||
200, 301, 302);
|
200, 301, 302);
|
||||||
|
|
||||||
// Now three more points.
|
// Now three more points.
|
||||||
|
|
|
@ -77,7 +77,7 @@ TYPES OF ENTITIES
|
||||||
SLVS_E_POINT_IN_3D
|
SLVS_E_POINT_IN_3D
|
||||||
|
|
||||||
A point in 3d. Defined by three parameters:
|
A point in 3d. Defined by three parameters:
|
||||||
|
|
||||||
param[0] the point's x coordinate
|
param[0] the point's x coordinate
|
||||||
param[1] y
|
param[1] y
|
||||||
param[1] z
|
param[1] z
|
||||||
|
@ -122,7 +122,7 @@ SLVS_E_NORMAL_IN_3D
|
||||||
|
|
||||||
defines a 3x3 rotation matrix. So U, V, and N all have unit length,
|
defines a 3x3 rotation matrix. So U, V, and N all have unit length,
|
||||||
and are orthogonal so that
|
and are orthogonal so that
|
||||||
|
|
||||||
U cross V = N
|
U cross V = N
|
||||||
V cross N = U
|
V cross N = U
|
||||||
N cross U = V
|
N cross U = V
|
||||||
|
@ -181,7 +181,7 @@ SLVS_E_WORKPLANE
|
||||||
|
|
||||||
|
|
||||||
SLVS_E_LINE_SEGMENT
|
SLVS_E_LINE_SEGMENT
|
||||||
|
|
||||||
A line segment between two endpoints
|
A line segment between two endpoints
|
||||||
|
|
||||||
point[0]
|
point[0]
|
||||||
|
@ -211,7 +211,7 @@ SLVS_E_CIRCLE
|
||||||
normal
|
normal
|
||||||
|
|
||||||
The circle is centered at
|
The circle is centered at
|
||||||
|
|
||||||
point[0]
|
point[0]
|
||||||
|
|
||||||
The circle's radius is
|
The circle's radius is
|
||||||
|
@ -356,7 +356,7 @@ SLVS_C_SYMMETRIC_LINE**
|
||||||
SLVS_C_AT_MIDPOINT*
|
SLVS_C_AT_MIDPOINT*
|
||||||
|
|
||||||
The point ptA lies at the midpoint of the line entityA.
|
The point ptA lies at the midpoint of the line entityA.
|
||||||
|
|
||||||
SLVS_C_HORIZONTAL
|
SLVS_C_HORIZONTAL
|
||||||
SLVS_C_VERTICAL**
|
SLVS_C_VERTICAL**
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ Imports System.Runtime.InteropServices
|
||||||
Module VbDemo
|
Module VbDemo
|
||||||
|
|
||||||
' Call our example functions, which set up some kind of sketch, solve
|
' Call our example functions, which set up some kind of sketch, solve
|
||||||
' it, and then print the result.
|
' it, and then print the result.
|
||||||
Sub Main()
|
Sub Main()
|
||||||
Console.WriteLine("EXAMPLE IN 3d (by objects):")
|
Console.WriteLine("EXAMPLE IN 3d (by objects):")
|
||||||
Example3dWithObjects()
|
Example3dWithObjects()
|
||||||
|
@ -42,13 +42,13 @@ Module VbDemo
|
||||||
' classes allow us to represent entities (e.g., lines and points)
|
' classes allow us to represent entities (e.g., lines and points)
|
||||||
' as .net objects. So we create an Slvs object, which will contain
|
' as .net objects. So we create an Slvs object, which will contain
|
||||||
' the entire sketch, with all the entities and constraints.
|
' the entire sketch, with all the entities and constraints.
|
||||||
'
|
'
|
||||||
' We then create entity objects (for example, points and lines)
|
' We then create entity objects (for example, points and lines)
|
||||||
' associated with that sketch, indicating the initial positions of
|
' associated with that sketch, indicating the initial positions of
|
||||||
' those entities and any hierarchical relationships among them (e.g.,
|
' those entities and any hierarchical relationships among them (e.g.,
|
||||||
' defining a line entity in terms of endpoint entities). We also add
|
' defining a line entity in terms of endpoint entities). We also add
|
||||||
' constraints associated with those entities.
|
' constraints associated with those entities.
|
||||||
'
|
'
|
||||||
' Finally, we solve, and print the new positions of the entities. If the
|
' Finally, we solve, and print the new positions of the entities. If the
|
||||||
' solution succeeded, then the entities will satisfy the constraints. If
|
' solution succeeded, then the entities will satisfy the constraints. If
|
||||||
' not, then the solver will suggest problematic constraints that, if
|
' not, then the solver will suggest problematic constraints that, if
|
||||||
|
@ -598,7 +598,7 @@ Module VbDemo
|
||||||
Return Result
|
Return Result
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
' After a call to Solve(), this returns the number of unconstrained
|
' After a call to Solve(), this returns the number of unconstrained
|
||||||
' degrees of freedom for the sketch.
|
' degrees of freedom for the sketch.
|
||||||
Public Function GetDof() As Integer
|
Public Function GetDof() As Integer
|
||||||
Return Dof
|
Return Dof
|
||||||
|
|
|
@ -349,7 +349,7 @@ void Constraint::MenuConstrain(int id) {
|
||||||
c.entityA = gs.entity[0];
|
c.entityA = gs.entity[0];
|
||||||
c.ptA = gs.point[0];
|
c.ptA = gs.point[0];
|
||||||
c.ptB = gs.point[1];
|
c.ptB = gs.point[1];
|
||||||
} else if(gs.lineSegments == 1 &&
|
} else if(gs.lineSegments == 1 &&
|
||||||
((gs.workplanes == 1 && gs.n == 2) ||
|
((gs.workplanes == 1 && gs.n == 2) ||
|
||||||
(gs.n == 1)))
|
(gs.n == 1)))
|
||||||
{
|
{
|
||||||
|
@ -490,7 +490,7 @@ void Constraint::MenuConstrain(int id) {
|
||||||
// normal vector; allow that, since the numerical
|
// normal vector; allow that, since the numerical
|
||||||
// constraint does
|
// constraint does
|
||||||
SWAP(Vector, ru, rv);
|
SWAP(Vector, ru, rv);
|
||||||
}
|
}
|
||||||
fu = fu.Dot(ru) > 0 ? ru : ru.ScaledBy(-1);
|
fu = fu.Dot(ru) > 0 ? ru : ru.ScaledBy(-1);
|
||||||
fv = fv.Dot(rv) > 0 ? rv : rv.ScaledBy(-1);
|
fv = fv.Dot(rv) > 0 ? rv : rv.ScaledBy(-1);
|
||||||
|
|
||||||
|
@ -548,7 +548,7 @@ void Constraint::MenuConstrain(int id) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Entity *ea = SK.GetEntity(c.entityA),
|
Entity *ea = SK.GetEntity(c.entityA),
|
||||||
*eb = SK.GetEntity(c.entityB);
|
*eb = SK.GetEntity(c.entityB);
|
||||||
if(ea->type == Entity::LINE_SEGMENT &&
|
if(ea->type == Entity::LINE_SEGMENT &&
|
||||||
eb->type == Entity::LINE_SEGMENT)
|
eb->type == Entity::LINE_SEGMENT)
|
||||||
|
|
|
@ -389,7 +389,7 @@ void ConstraintBase::GenerateReal(IdList<Equation,hEquation> *l) {
|
||||||
// the line segment, and choose the longer of these.
|
// the line segment, and choose the longer of these.
|
||||||
ExprVector eap = ea.Minus(ep);
|
ExprVector eap = ea.Minus(ep);
|
||||||
ExprVector ebp = eb.Minus(ep);
|
ExprVector ebp = eb.Minus(ep);
|
||||||
ExprVector elp =
|
ExprVector elp =
|
||||||
(ebp.Magnitude()->Eval() > eap.Magnitude()->Eval()) ?
|
(ebp.Magnitude()->Eval() > eap.Magnitude()->Eval()) ?
|
||||||
ebp : eap;
|
ebp : eap;
|
||||||
|
|
||||||
|
@ -413,7 +413,7 @@ void ConstraintBase::GenerateReal(IdList<Equation,hEquation> *l) {
|
||||||
EntityBase *normal = SK.GetEntity(circle->normal);
|
EntityBase *normal = SK.GetEntity(circle->normal);
|
||||||
ExprVector u = normal->NormalExprsU(),
|
ExprVector u = normal->NormalExprsU(),
|
||||||
v = normal->NormalExprsV();
|
v = normal->NormalExprsV();
|
||||||
|
|
||||||
Expr *du = (center.Minus(pt)).Dot(u),
|
Expr *du = (center.Minus(pt)).Dot(u),
|
||||||
*dv = (center.Minus(pt)).Dot(v);
|
*dv = (center.Minus(pt)).Dot(v);
|
||||||
|
|
||||||
|
@ -443,7 +443,7 @@ void ConstraintBase::GenerateReal(IdList<Equation,hEquation> *l) {
|
||||||
EntityBase *ln = SK.GetEntity(entityA);
|
EntityBase *ln = SK.GetEntity(entityA);
|
||||||
EntityBase *a = SK.GetEntity(ln->point[0]);
|
EntityBase *a = SK.GetEntity(ln->point[0]);
|
||||||
EntityBase *b = SK.GetEntity(ln->point[1]);
|
EntityBase *b = SK.GetEntity(ln->point[1]);
|
||||||
|
|
||||||
Expr *au, *av, *bu, *bv;
|
Expr *au, *av, *bu, *bv;
|
||||||
a->PointGetExprsInWorkplane(workplane, &au, &av);
|
a->PointGetExprsInWorkplane(workplane, &au, &av);
|
||||||
b->PointGetExprsInWorkplane(workplane, &bu, &bv);
|
b->PointGetExprsInWorkplane(workplane, &bu, &bv);
|
||||||
|
@ -601,7 +601,7 @@ void ConstraintBase::GenerateReal(IdList<Equation,hEquation> *l) {
|
||||||
ExprVector bu = b->NormalExprsU(),
|
ExprVector bu = b->NormalExprsU(),
|
||||||
bv = b->NormalExprsV(),
|
bv = b->NormalExprsV(),
|
||||||
bn = b->NormalExprsN();
|
bn = b->NormalExprsN();
|
||||||
|
|
||||||
AddEq(l, VectorsParallel(0, an, bn), 0);
|
AddEq(l, VectorsParallel(0, an, bn), 0);
|
||||||
AddEq(l, VectorsParallel(1, an, bn), 1);
|
AddEq(l, VectorsParallel(1, an, bn), 1);
|
||||||
Expr *d1 = au.Dot(bv);
|
Expr *d1 = au.Dot(bv);
|
||||||
|
@ -662,7 +662,7 @@ void ConstraintBase::GenerateReal(IdList<Equation,hEquation> *l) {
|
||||||
EntityBase *line = SK.GetEntity(entityB);
|
EntityBase *line = SK.GetEntity(entityB);
|
||||||
|
|
||||||
ExprVector ac = SK.GetEntity(arc->point[0])->PointGetExprs();
|
ExprVector ac = SK.GetEntity(arc->point[0])->PointGetExprs();
|
||||||
ExprVector ap =
|
ExprVector ap =
|
||||||
SK.GetEntity(arc->point[other ? 2 : 1])->PointGetExprs();
|
SK.GetEntity(arc->point[other ? 2 : 1])->PointGetExprs();
|
||||||
|
|
||||||
ExprVector ld = line->VectorGetExprs();
|
ExprVector ld = line->VectorGetExprs();
|
||||||
|
@ -675,7 +675,7 @@ void ConstraintBase::GenerateReal(IdList<Equation,hEquation> *l) {
|
||||||
case CUBIC_LINE_TANGENT: {
|
case CUBIC_LINE_TANGENT: {
|
||||||
EntityBase *cubic = SK.GetEntity(entityA);
|
EntityBase *cubic = SK.GetEntity(entityA);
|
||||||
EntityBase *line = SK.GetEntity(entityB);
|
EntityBase *line = SK.GetEntity(entityB);
|
||||||
|
|
||||||
ExprVector a;
|
ExprVector a;
|
||||||
if(other) {
|
if(other) {
|
||||||
a = cubic->CubicGetFinishTangentExprs();
|
a = cubic->CubicGetFinishTangentExprs();
|
||||||
|
|
|
@ -33,7 +33,7 @@ public:
|
||||||
Quaternion ScaledBy(double s);
|
Quaternion ScaledBy(double s);
|
||||||
double Magnitude(void);
|
double Magnitude(void);
|
||||||
Quaternion WithMagnitude(double s);
|
Quaternion WithMagnitude(double s);
|
||||||
|
|
||||||
// Call a rotation matrix [ u' v' n' ]'; this returns the first and
|
// Call a rotation matrix [ u' v' n' ]'; this returns the first and
|
||||||
// second rows, where that matrix is generated by this quaternion
|
// second rows, where that matrix is generated by this quaternion
|
||||||
Vector RotationU(void);
|
Vector RotationU(void);
|
||||||
|
@ -50,7 +50,7 @@ public:
|
||||||
class Vector {
|
class Vector {
|
||||||
public:
|
public:
|
||||||
double x, y, z;
|
double x, y, z;
|
||||||
|
|
||||||
static Vector From(double x, double y, double z);
|
static Vector From(double x, double y, double z);
|
||||||
static Vector From(hParam x, hParam y, hParam z);
|
static Vector From(hParam x, hParam y, hParam z);
|
||||||
static Vector AtIntersectionOfPlanes(Vector n1, double d1,
|
static Vector AtIntersectionOfPlanes(Vector n1, double d1,
|
||||||
|
@ -101,7 +101,7 @@ public:
|
||||||
static bool BoundingBoxIntersectsLine(Vector amax, Vector amin,
|
static bool BoundingBoxIntersectsLine(Vector amax, Vector amin,
|
||||||
Vector p0, Vector p1, bool segment);
|
Vector p0, Vector p1, bool segment);
|
||||||
bool OutsideAndNotOn(Vector maxv, Vector minv);
|
bool OutsideAndNotOn(Vector maxv, Vector minv);
|
||||||
Vector InPerspective(Vector u, Vector v, Vector n,
|
Vector InPerspective(Vector u, Vector v, Vector n,
|
||||||
Vector origin, double cameraTan);
|
Vector origin, double cameraTan);
|
||||||
Point2d Project2d(Vector u, Vector v);
|
Point2d Project2d(Vector u, Vector v);
|
||||||
Point2d ProjectXy(void);
|
Point2d ProjectXy(void);
|
||||||
|
@ -111,7 +111,7 @@ public:
|
||||||
class Vector4 {
|
class Vector4 {
|
||||||
public:
|
public:
|
||||||
double w, x, y, z;
|
double w, x, y, z;
|
||||||
|
|
||||||
static Vector4 From(double w, double x, double y, double z);
|
static Vector4 From(double w, double x, double y, double z);
|
||||||
static Vector4 From(double w, Vector v3);
|
static Vector4 From(double w, Vector v3);
|
||||||
static Vector4 Blend(Vector4 a, Vector4 b, double t);
|
static Vector4 Blend(Vector4 a, Vector4 b, double t);
|
||||||
|
|
|
@ -280,7 +280,7 @@ void EntityBase::NormalForceTo(Quaternion q) {
|
||||||
break;
|
break;
|
||||||
case NORMAL_N_ROT: {
|
case NORMAL_N_ROT: {
|
||||||
Quaternion qp = q.Times(numNormal.Inverse());
|
Quaternion qp = q.Times(numNormal.Inverse());
|
||||||
|
|
||||||
SK.GetParam(param[0])->val = qp.w;
|
SK.GetParam(param[0])->val = qp.w;
|
||||||
SK.GetParam(param[1])->val = qp.vx;
|
SK.GetParam(param[1])->val = qp.vx;
|
||||||
SK.GetParam(param[2])->val = qp.vy;
|
SK.GetParam(param[2])->val = qp.vy;
|
||||||
|
@ -756,8 +756,8 @@ void EntityBase::GenerateEquations(IdList<Equation,hEquation> *l) {
|
||||||
ConstraintBase *c = &(SK.constraint.elem[i]);
|
ConstraintBase *c = &(SK.constraint.elem[i]);
|
||||||
if(c->group.v != group.v) continue;
|
if(c->group.v != group.v) continue;
|
||||||
if(c->type != Constraint::POINTS_COINCIDENT) continue;
|
if(c->type != Constraint::POINTS_COINCIDENT) continue;
|
||||||
|
|
||||||
if((c->ptA.v == point[1].v && c->ptB.v == point[2].v) ||
|
if((c->ptA.v == point[1].v && c->ptB.v == point[2].v) ||
|
||||||
(c->ptA.v == point[2].v && c->ptB.v == point[1].v))
|
(c->ptA.v == point[2].v && c->ptB.v == point[1].v))
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -346,7 +346,7 @@ Expr *Expr::PartialWrt(hParam p) {
|
||||||
db = b->PartialWrt(p);
|
db = b->PartialWrt(p);
|
||||||
return (a->Times(db))->Plus(b->Times(da));
|
return (a->Times(db))->Plus(b->Times(da));
|
||||||
|
|
||||||
case DIV:
|
case DIV:
|
||||||
da = a->PartialWrt(p);
|
da = a->PartialWrt(p);
|
||||||
db = b->PartialWrt(p);
|
db = b->PartialWrt(p);
|
||||||
return ((da->Times(b))->Minus(a->Times(db)))->Div(b->Square());
|
return ((da->Times(b))->Minus(a->Times(db)))->Div(b->Square());
|
||||||
|
@ -673,7 +673,7 @@ void Expr::Parse(void) {
|
||||||
for(;;) {
|
for(;;) {
|
||||||
Expr *n = Next();
|
Expr *n = Next();
|
||||||
if(!n) throw "end of expression unexpected";
|
if(!n) throw "end of expression unexpected";
|
||||||
|
|
||||||
if(n->op == CONSTANT) {
|
if(n->op == CONSTANT) {
|
||||||
PushOperand(n);
|
PushOperand(n);
|
||||||
Consume();
|
Consume();
|
||||||
|
|
|
@ -78,7 +78,7 @@ void Slvs_Solve(Slvs_System *ssys, Slvs_hGroup shg)
|
||||||
Slvs_Param *sp = &(ssys->param[i]);
|
Slvs_Param *sp = &(ssys->param[i]);
|
||||||
Param p;
|
Param p;
|
||||||
ZERO(&p);
|
ZERO(&p);
|
||||||
|
|
||||||
p.h.v = sp->h;
|
p.h.v = sp->h;
|
||||||
p.val = sp->val;
|
p.val = sp->val;
|
||||||
SK.param.Add(&p);
|
SK.param.Add(&p);
|
||||||
|
|
|
@ -272,7 +272,7 @@ public:
|
||||||
bool construction;
|
bool construction;
|
||||||
NameStr str;
|
NameStr str;
|
||||||
NameStr font;
|
NameStr font;
|
||||||
|
|
||||||
static hParam AddParam(ParamList *param, hParam hp);
|
static hParam AddParam(ParamList *param, hParam hp);
|
||||||
void Generate(EntityList *entity, ParamList *param);
|
void Generate(EntityList *entity, ParamList *param);
|
||||||
|
|
||||||
|
@ -659,7 +659,7 @@ class Style {
|
||||||
public:
|
public:
|
||||||
int tag;
|
int tag;
|
||||||
hStyle h;
|
hStyle h;
|
||||||
|
|
||||||
// If an entity has no style, then it will be colored according to
|
// If an entity has no style, then it will be colored according to
|
||||||
// whether the group that it's in is active or not, whether it's
|
// whether the group that it's in is active or not, whether it's
|
||||||
// construction or not, and so on.
|
// construction or not, and so on.
|
||||||
|
|
10
src/slvs.h
10
src/slvs.h
|
@ -11,9 +11,9 @@
|
||||||
#define __SLVS_H
|
#define __SLVS_H
|
||||||
|
|
||||||
#ifdef EXPORT_DLL
|
#ifdef EXPORT_DLL
|
||||||
#define DLL __declspec( dllexport )
|
#define DLL __declspec( dllexport )
|
||||||
#else
|
#else
|
||||||
#define DLL __declspec( dllimport )
|
#define DLL __declspec( dllimport )
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
@ -118,7 +118,7 @@ typedef struct {
|
||||||
Slvs_hEntity entityB;
|
Slvs_hEntity entityB;
|
||||||
Slvs_hEntity entityC;
|
Slvs_hEntity entityC;
|
||||||
Slvs_hEntity entityD;
|
Slvs_hEntity entityD;
|
||||||
|
|
||||||
int other;
|
int other;
|
||||||
int other2;
|
int other2;
|
||||||
} Slvs_Constraint;
|
} Slvs_Constraint;
|
||||||
|
@ -158,10 +158,10 @@ typedef struct {
|
||||||
int calculateFaileds;
|
int calculateFaileds;
|
||||||
|
|
||||||
//// OUTPUT VARIABLES
|
//// OUTPUT VARIABLES
|
||||||
//
|
//
|
||||||
// If the solver fails, then it can report which constraints are causing
|
// If the solver fails, then it can report which constraints are causing
|
||||||
// the problem. The caller should allocate the array failed[], and pass
|
// the problem. The caller should allocate the array failed[], and pass
|
||||||
// its size in faileds.
|
// its size in faileds.
|
||||||
//
|
//
|
||||||
// The solver will set faileds equal to the number of problematic
|
// The solver will set faileds equal to the number of problematic
|
||||||
// constraints, and write their Slvs_hConstraints into failed[]. To
|
// constraints, and write their Slvs_hConstraints into failed[]. To
|
||||||
|
|
|
@ -328,7 +328,7 @@ public:
|
||||||
bool onCurve;
|
bool onCurve;
|
||||||
bool lastInContour;
|
bool lastInContour;
|
||||||
SWORD x;
|
SWORD x;
|
||||||
SWORD y;
|
SWORD y;
|
||||||
} FontPoint;
|
} FontPoint;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -380,7 +380,7 @@ public:
|
||||||
void LoadGlyph(int index);
|
void LoadGlyph(int index);
|
||||||
bool LoadFontFromFile(bool nameOnly);
|
bool LoadFontFromFile(bool nameOnly);
|
||||||
char *FontFileBaseName(void);
|
char *FontFileBaseName(void);
|
||||||
|
|
||||||
void Flush(void);
|
void Flush(void);
|
||||||
void Handle(int *dx, int x, int y, bool onCurve);
|
void Handle(int *dx, int x, int y, bool onCurve);
|
||||||
void PlotCharacter(int *dx, int c, double spacing);
|
void PlotCharacter(int *dx, int c, double spacing);
|
||||||
|
|
|
@ -197,7 +197,7 @@ public:
|
||||||
hSSurface surfA;
|
hSSurface surfA;
|
||||||
hSSurface surfB;
|
hSSurface surfB;
|
||||||
|
|
||||||
static SCurve FromTransformationOf(SCurve *a, Vector t, Quaternion q,
|
static SCurve FromTransformationOf(SCurve *a, Vector t, Quaternion q,
|
||||||
double scale);
|
double scale);
|
||||||
SCurve MakeCopySplitAgainst(SShell *agnstA, SShell *agnstB,
|
SCurve MakeCopySplitAgainst(SShell *agnstA, SShell *agnstB,
|
||||||
SSurface *srfA, SSurface *srfB);
|
SSurface *srfA, SSurface *srfB);
|
||||||
|
@ -275,13 +275,13 @@ public:
|
||||||
void EdgeNormalsWithinSurface(Point2d auv, Point2d buv,
|
void EdgeNormalsWithinSurface(Point2d auv, Point2d buv,
|
||||||
Vector *pt, Vector *enin, Vector *enout,
|
Vector *pt, Vector *enin, Vector *enout,
|
||||||
Vector *surfn,
|
Vector *surfn,
|
||||||
DWORD auxA,
|
DWORD auxA,
|
||||||
SShell *shell, SShell *sha, SShell *shb);
|
SShell *shell, SShell *sha, SShell *shb);
|
||||||
void FindChainAvoiding(SEdgeList *src, SEdgeList *dest, SPointList *avoid);
|
void FindChainAvoiding(SEdgeList *src, SEdgeList *dest, SPointList *avoid);
|
||||||
SSurface MakeCopyTrimAgainst(SShell *parent, SShell *a, SShell *b,
|
SSurface MakeCopyTrimAgainst(SShell *parent, SShell *a, SShell *b,
|
||||||
SShell *into, int type);
|
SShell *into, int type);
|
||||||
void TrimFromEdgeList(SEdgeList *el, bool asUv);
|
void TrimFromEdgeList(SEdgeList *el, bool asUv);
|
||||||
void IntersectAgainst(SSurface *b, SShell *agnstA, SShell *agnstB,
|
void IntersectAgainst(SSurface *b, SShell *agnstA, SShell *agnstB,
|
||||||
SShell *into);
|
SShell *into);
|
||||||
void AddExactIntersectionCurve(SBezier *sb, SSurface *srfB,
|
void AddExactIntersectionCurve(SBezier *sb, SSurface *srfB,
|
||||||
SShell *agnstA, SShell *agnstB, SShell *into);
|
SShell *agnstA, SShell *agnstB, SShell *into);
|
||||||
|
@ -388,7 +388,7 @@ public:
|
||||||
int ClassifyRegion(Vector edge_n, Vector inter_surf_n, Vector edge_surf_n);
|
int ClassifyRegion(Vector edge_n, Vector inter_surf_n, Vector edge_surf_n);
|
||||||
bool ClassifyEdge(int *indir, int *outdir,
|
bool ClassifyEdge(int *indir, int *outdir,
|
||||||
Vector ea, Vector eb,
|
Vector ea, Vector eb,
|
||||||
Vector p,
|
Vector p,
|
||||||
Vector edge_n_in, Vector edge_n_out, Vector surf_n);
|
Vector edge_n_in, Vector edge_n_out, Vector surf_n);
|
||||||
|
|
||||||
void MakeFromCopyOf(SShell *a);
|
void MakeFromCopyOf(SShell *a);
|
||||||
|
|
|
@ -289,7 +289,7 @@ bool System::NewtonSolve(int tag) {
|
||||||
|
|
||||||
if(!SolveLeastSquares()) break;
|
if(!SolveLeastSquares()) break;
|
||||||
|
|
||||||
// Take the Newton step;
|
// Take the Newton step;
|
||||||
// J(x_n) (x_{n+1} - x_n) = 0 - F(x_n)
|
// J(x_n) (x_{n+1} - x_n) = 0 - F(x_n)
|
||||||
for(i = 0; i < mat.n; i++) {
|
for(i = 0; i < mat.n; i++) {
|
||||||
Param *p = param.FindById(mat.param[i]);
|
Param *p = param.FindById(mat.param[i]);
|
||||||
|
@ -393,7 +393,7 @@ void System::FindWhichToRemoveToFixJacobian(Group *g, List<hConstraint> *bad) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int System::Solve(Group *g, int *dof, List<hConstraint> *bad,
|
int System::Solve(Group *g, int *dof, List<hConstraint> *bad,
|
||||||
bool andFindBad, bool andFindFree)
|
bool andFindBad, bool andFindFree)
|
||||||
{
|
{
|
||||||
WriteEquationsExceptFor(Constraint::NO_CONSTRAINT, g);
|
WriteEquationsExceptFor(Constraint::NO_CONSTRAINT, g);
|
||||||
|
@ -412,7 +412,7 @@ int System::Solve(Group *g, int *dof, List<hConstraint> *bad,
|
||||||
// All params and equations are assigned to group zero.
|
// All params and equations are assigned to group zero.
|
||||||
param.ClearTags();
|
param.ClearTags();
|
||||||
eq.ClearTags();
|
eq.ClearTags();
|
||||||
|
|
||||||
SolveBySubstitution();
|
SolveBySubstitution();
|
||||||
|
|
||||||
// Before solving the big system, see if we can find any equations that
|
// Before solving the big system, see if we can find any equations that
|
||||||
|
@ -522,7 +522,7 @@ didnt_converge:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return System::DIDNT_CONVERGE;
|
return System::DIDNT_CONVERGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
10
src/ui.h
10
src/ui.h
|
@ -93,12 +93,12 @@ public:
|
||||||
BYTE *HsvPattern1d(double h, double s);
|
BYTE *HsvPattern1d(double h, double s);
|
||||||
void ColorPickerDone(void);
|
void ColorPickerDone(void);
|
||||||
bool DrawOrHitTestColorPicker(int how, bool leftDown, double x, double y);
|
bool DrawOrHitTestColorPicker(int how, bool leftDown, double x, double y);
|
||||||
|
|
||||||
void Init(void);
|
void Init(void);
|
||||||
void MakeColorTable(const Color *in, float *out);
|
void MakeColorTable(const Color *in, float *out);
|
||||||
void Printf(bool half, char *fmt, ...);
|
void Printf(bool half, char *fmt, ...);
|
||||||
void ClearScreen(void);
|
void ClearScreen(void);
|
||||||
|
|
||||||
void Show(void);
|
void Show(void);
|
||||||
|
|
||||||
// State for the screen that we are showing in the text window.
|
// State for the screen that we are showing in the text window.
|
||||||
|
@ -506,7 +506,7 @@ public:
|
||||||
hEntity circle;
|
hEntity circle;
|
||||||
hEntity normal;
|
hEntity normal;
|
||||||
hConstraint constraint;
|
hConstraint constraint;
|
||||||
|
|
||||||
char *description;
|
char *description;
|
||||||
} pending;
|
} pending;
|
||||||
void ClearPending(void);
|
void ClearPending(void);
|
||||||
|
@ -525,7 +525,7 @@ public:
|
||||||
Vector p0, p1;
|
Vector p0, p1;
|
||||||
Vector u, v;
|
Vector u, v;
|
||||||
double r, theta0, theta1, dtheta;
|
double r, theta0, theta1, dtheta;
|
||||||
|
|
||||||
void MakeFromEntity(hEntity he, bool reverse);
|
void MakeFromEntity(hEntity he, bool reverse);
|
||||||
Vector PointAt(double t);
|
Vector PointAt(double t);
|
||||||
Vector TangentAt(double t);
|
Vector TangentAt(double t);
|
||||||
|
@ -544,7 +544,7 @@ public:
|
||||||
void ReplacePointInConstraints(hEntity oldpt, hEntity newpt);
|
void ReplacePointInConstraints(hEntity oldpt, hEntity newpt);
|
||||||
void FixConstraintsForRequestBeingDeleted(hRequest hr);
|
void FixConstraintsForRequestBeingDeleted(hRequest hr);
|
||||||
void FixConstraintsForPointBeingDeleted(hEntity hpt);
|
void FixConstraintsForPointBeingDeleted(hEntity hpt);
|
||||||
|
|
||||||
// The current selection.
|
// The current selection.
|
||||||
class Selection {
|
class Selection {
|
||||||
public:
|
public:
|
||||||
|
|
14
src/util.cpp
14
src/util.cpp
|
@ -99,7 +99,7 @@ bool StringEndsIn(char *str, char *ending)
|
||||||
int i, ls = strlen(str), le = strlen(ending);
|
int i, ls = strlen(str), le = strlen(ending);
|
||||||
|
|
||||||
if(ls < le) return false;
|
if(ls < le) return false;
|
||||||
|
|
||||||
for(i = 0; i < le; i++) {
|
for(i = 0; i < le; i++) {
|
||||||
if(tolower(ending[le-i-1]) != tolower(str[ls-i-1])) {
|
if(tolower(ending[le-i-1]) != tolower(str[ls-i-1])) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -601,7 +601,7 @@ Vector Vector::ScaleOutOfCsys(Vector u, Vector v, Vector n) {
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector Vector::InPerspective(Vector u, Vector v, Vector n,
|
Vector Vector::InPerspective(Vector u, Vector v, Vector n,
|
||||||
Vector origin, double cameraTan)
|
Vector origin, double cameraTan)
|
||||||
{
|
{
|
||||||
Vector r = this->Minus(origin);
|
Vector r = this->Minus(origin);
|
||||||
|
@ -742,7 +742,7 @@ Vector Vector::ClosestOrtho(void) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector Vector::ClampWithin(double minv, double maxv) {
|
Vector Vector::ClampWithin(double minv, double maxv) {
|
||||||
Vector ret = *this;
|
Vector ret = *this;
|
||||||
|
|
||||||
if(ret.x < minv) ret.x = minv;
|
if(ret.x < minv) ret.x = minv;
|
||||||
|
@ -820,11 +820,11 @@ bool Vector::BoundingBoxIntersectsLine(Vector amax, Vector amin,
|
||||||
Vector Vector::AtIntersectionOfPlanes(Vector n1, double d1,
|
Vector Vector::AtIntersectionOfPlanes(Vector n1, double d1,
|
||||||
Vector n2, double d2)
|
Vector n2, double d2)
|
||||||
{
|
{
|
||||||
double det = (n1.Dot(n1))*(n2.Dot(n2)) -
|
double det = (n1.Dot(n1))*(n2.Dot(n2)) -
|
||||||
(n1.Dot(n2))*(n1.Dot(n2));
|
(n1.Dot(n2))*(n1.Dot(n2));
|
||||||
double c1 = (d1*n2.Dot(n2) - d2*n1.Dot(n2))/det;
|
double c1 = (d1*n2.Dot(n2) - d2*n1.Dot(n2))/det;
|
||||||
double c2 = (d2*n1.Dot(n1) - d1*n1.Dot(n2))/det;
|
double c2 = (d2*n1.Dot(n1) - d1*n1.Dot(n2))/det;
|
||||||
|
|
||||||
return (n1.ScaledBy(c1)).Plus(n2.ScaledBy(c2));
|
return (n1.ScaledBy(c1)).Plus(n2.ScaledBy(c2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -846,7 +846,7 @@ void Vector::ClosestPointBetweenLines(Vector a0, Vector da,
|
||||||
// So dot this equation against dna and dnb to get two equations
|
// So dot this equation against dna and dnb to get two equations
|
||||||
// to solve for da and db
|
// to solve for da and db
|
||||||
*tb = ((a0.Minus(b0)).Dot(dna))/(db.Dot(dna));
|
*tb = ((a0.Minus(b0)).Dot(dna))/(db.Dot(dna));
|
||||||
*ta = -((a0.Minus(b0)).Dot(dnb))/(da.Dot(dnb));
|
*ta = -((a0.Minus(b0)).Dot(dnb))/(da.Dot(dnb));
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector Vector::AtIntersectionOfLines(Vector a0, Vector a1,
|
Vector Vector::AtIntersectionOfLines(Vector a0, Vector a1,
|
||||||
|
@ -1039,7 +1039,7 @@ double Point2d::Dot(Point2d p) {
|
||||||
double Point2d::DistanceToLine(Point2d p0, Point2d dp, bool segment) {
|
double Point2d::DistanceToLine(Point2d p0, Point2d dp, bool segment) {
|
||||||
double m = dp.x*dp.x + dp.y*dp.y;
|
double m = dp.x*dp.x + dp.y*dp.y;
|
||||||
if(m < LENGTH_EPS*LENGTH_EPS) return VERY_POSITIVE;
|
if(m < LENGTH_EPS*LENGTH_EPS) return VERY_POSITIVE;
|
||||||
|
|
||||||
// Let our line be p = p0 + t*dp, for a scalar t from 0 to 1
|
// Let our line be p = p0 + t*dp, for a scalar t from 0 to 1
|
||||||
double t = (dp.x*(x - p0.x) + dp.y*(y - p0.y))/m;
|
double t = (dp.x*(x - p0.x) + dp.y*(y - p0.y))/m;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user