Commit Graph

267 Commits (22afc5ea150a7762e1f405641adfd5f8633fb271)

Author SHA1 Message Date
Jonathan Westhues aa5c621d82 Add symmetry constraints without an explicit symmetry plane; these
use the horizontal or vertical axes of the active workplane. The
equations that we write from these are very fast (of the form u + v
= 0, or u - v = 0).

[git-p4: depot-paths = "//depot/solvespace/": change = 1720]
2008-05-13 02:38:21 -08:00
Jonathan Westhues 6031c99bec Scale columns of the Jacobian before least squares solving; this
lets me reweight the parameters, e.g. to encourage the solver to
make changes to the point being dragged.

[git-p4: depot-paths = "//depot/solvespace/": change = 1719]
2008-05-12 18:35:31 -08:00
Jonathan Westhues 364938f332 Add an arc entity. That's not allowed to exist in free space (since
we need something to force the points into plane, and the workplane
supplies that), but otherwise straightforward. And add diameter and
equal radius constraints for the arc.

[git-p4: depot-paths = "//depot/solvespace/": change = 1718]
2008-05-12 02:01:44 -08:00
Jonathan Westhues f4d2651031 Get rid of assumptions, which always did cause trouble. Instead,
solve the Newton's method iterations in a least squares sense. This
is much less likely to result in numerical disaster; a parameter
will never make a very large change, unless that really is the only
way to satisfy the constraints.

[git-p4: depot-paths = "//depot/solvespace/": change = 1717]
2008-05-11 23:29:50 -08:00
Jonathan Westhues e2263c69c8 Find a memory corruption! I was getting a pointer into the entity
list, and then adding a new entity to that list, and then looking
at that pointer again. Not okay; the add operation might have
forced a realloc. I have to watch for that.

And add a "distance ratio" constraint, plus a new kind of group
that comes with its own workplane. The workplane is not solved for;
it's generated explicitly in terms of elements that are already
solved.

[git-p4: depot-paths = "//depot/solvespace/": change = 1716]
2008-05-11 02:40:37 -08:00
Jonathan Westhues 6042fb3e0f Add transformed points and normals with a rotation (as well as a
translation; or equivalently, rotation about an arbitrary axis).
Those will be important for step and repeats, and for imported
parts.

Also fix a terrible memory corruption bug: I was freeing the remap
list after I loaded it from the file, but the code that put that
into the SS.group list made only a shallow copy.

[git-p4: depot-paths = "//depot/solvespace/": change = 1715]
2008-05-10 22:09:46 -08:00
Jonathan Westhues 4eed7693be Little changes, more pwls in a circle, and make "same orientation"
constraints work mod 180 degrees, so that it snaps to however the
workplane was drawn (more vertical vs. more horizontal).

[git-p4: depot-paths = "//depot/solvespace/": change = 1714]
2008-05-10 18:57:47 -08:00
Jonathan Westhues 10240cc1df Add parallel and same orientation constraints, that work on line
segments and normals.

[git-p4: depot-paths = "//depot/solvespace/": change = 1713]
2008-05-08 21:33:23 -08:00
Jonathan Westhues 018e8a0444 Draw an additional projection line, when showing a point-line
projected distance constraint.

[git-p4: depot-paths = "//depot/solvespace/": change = 1712]
2008-05-08 00:12:23 -08:00
Jonathan Westhues e11da119f0 Add point-line distance, point-plane distance, and point-on-circle
constraints. And generate the constraint equations for entities
(e.g., that our unit quaternions have magnitude one). Numerical
troubles there, but it sort of works. Also some stuff to draw
projection lines with projected constraints, and to auto-insert
more constraints as you draw.

[git-p4: depot-paths = "//depot/solvespace/": change = 1711]
2008-05-07 23:30:30 -08:00
Jonathan Westhues 328a946cc4 Add a diameter constraint, and add a `distance' entity that I can
remap when I copy circle entities, in order to make the radius
numerical somehow (analogy with the POINT_ and NORMAL_XFRMD) thing.

[git-p4: depot-paths = "//depot/solvespace/": change = 1710]
2008-05-07 00:19:37 -08:00
Jonathan Westhues c05659753a Add the substitution solver. That speeds things up a bit, and
improves the quality of assumptions.

[git-p4: depot-paths = "//depot/solvespace/": change = 1709]
2008-05-06 23:10:20 -08:00
Jonathan Westhues 6b264a6ba6 Add a convenience command to draw a rectangle (as four line
segments), add the toggle construction command, and color the lines
differently depending on what group you're in.

Also change dynamic memory stuff to use a Win32 heap for everything
(no malloc), and validate that often. I think I've seen it crash,
though I can't reproduce it.

[git-p4: depot-paths = "//depot/solvespace/": change = 1708]
2008-05-06 20:17:29 -08:00
Jonathan Westhues c767d55c71 Now we can add new workplanes. So fix all the mistakes that I
hadn't previously noticed, because I didn't use to have workplanes
with non-zero offsets. And clean up the interface to normals a bit.

[git-p4: depot-paths = "//depot/solvespace/": change = 1707]
2008-05-05 03:17:00 -08:00
Jonathan Westhues d048946adc Fix some stupid bugs introduced with the new representation of
workplanes. And fix up our polygon normals, so that everything gets
shaded correctly (and so that later we can generate our STL files
with correct normals).

[git-p4: depot-paths = "//depot/solvespace/": change = 1706]
2008-05-05 01:47:23 -08:00
Jonathan Westhues 853c6cb59c A big change, to add a concept of normals. These are "oriented
vectors", represented by unit quaternions. This permits me to add
circles, where the normal defines the plane of the circle.

Still many things painful. The interface for editing normals is not
so intuitive, and it's not yet clear how I would e.g. export a
circle entity and recreate it properly, since that entity has a
param not associated with a normal or point.

And the transformed points/normals do not yet support rotations.
That will be necessary soon.

[git-p4: depot-paths = "//depot/solvespace/": change = 1705]
2008-05-04 22:18:01 -08:00
Jonathan Westhues 01885736e6 Fix my rotation-matrix-to-quaternion code: it broke when the
diagonal elements of the matrix summed to -1. Now it's ugly, but I
think that it's correct. And add a command to flip the view to the
other side, which is what started my problems. And tweak display of
H and V and M for constraints: put them in the constraint plane, so
that they're stationary as you rotate around.

[git-p4: depot-paths = "//depot/solvespace/": change = 1704]
2008-05-02 19:33:35 -08:00
Jonathan Westhues 30636a6f29 Make the extrude command do a bit more; now I generate all the
faces of the polyhedron. And shade the faces when I draw them, and
fix up our projection matrix so that the depth testing works
properly.

[git-p4: depot-paths = "//depot/solvespace/": change = 1703]
2008-05-02 02:54:22 -08:00
Jonathan Westhues 658b7df50f Make at-midpoint constraint also work to constrain midpoint of a
line segment on a plane. And simplify that code a bit, and improve
display.

[git-p4: depot-paths = "//depot/solvespace/": change = 1702]
2008-04-30 22:53:50 -08:00
Jonathan Westhues b7e8b99f37 Don't blow up when the pending point doesn't seem to exist; that
happens if we're solving an earlier group than the one that
contains the pending point.

[git-p4: depot-paths = "//depot/solvespace/": change = 1701]
2008-04-30 22:38:00 -08:00
Jonathan Westhues f1c5d07e39 Sort the parameters by sensitivity before solving, and always sort
the point that's being dragged first, to guarantee that that one
gets the max possible degrees of freedom. The sort code (sort a
list of integers, then apply the permutations by swaps) was more
painful than it should have been.

[git-p4: depot-paths = "//depot/solvespace/": change = 1700]
2008-04-30 22:25:38 -08:00
Jonathan Westhues 498ffd07ea Add symmetric and at midpoint constraints. The symmetry constraint
turned out straightforward, in great part because the planes are
workplanes (6 DOF, represented by a unit quaternion and a point),
and therefore make it easy to get a vector in the plane, as well as
a normal.

And on that subject, replace the previous hack for parallel vector
constraints with a better hack: pivot on the initial numerical
guess, to choose which components of the cross product to drive to
zero. Ugly, but I think that will be as robust as I can get.

[git-p4: depot-paths = "//depot/solvespace/": change = 1699]
2008-04-30 00:14:32 -08:00
Jonathan Westhues 60925e4040 A ~10x speedup in the solver. Simplify equations before evaluating
or taking partials (constant folding). Also keep a little hash
table to mark with params are used in each equation, in order to
quickly discard trivial partial derivatives. This is solving a
64x64 system in <20 ms. I suspect this is now much faster than
Sketchflat.

Slightly fake situation, though, since substitution solver has not
yet been written, and no partitioning. I'll do those next.

[git-p4: depot-paths = "//depot/solvespace/": change = 1698]
2008-04-29 20:52:34 -08:00
Jonathan Westhues 70bf14530d Add point on line constraints, in 2d and 3d. The 3d equations do
not have much motivation behind them, but they seem to work. And
make sure that we don't solve multiple times without repainting in
between, and tweak the text window a bit more.

[git-p4: depot-paths = "//depot/solvespace/": change = 1696]
2008-04-28 01:40:02 -08:00
Jonathan Westhues 598d456d8d Tear apart the text window, mostly to beautify things. The
foreground and background colours are now specified separately, and
it's possible to insert half-line spaces. So now I have a window
that lets me show/hide groups, and select the active one.

[git-p4: depot-paths = "//depot/solvespace/": change = 1695]
2008-04-27 23:18:39 -08:00
Jonathan Westhues 01cff278bd Include the remap lists (when we copy entities, that we used to
assign the new ids) in the saved file, and split the file load from
table stuff into its own function.

[git-p4: depot-paths = "//depot/solvespace/": change = 1694]
2008-04-27 02:01:23 -08:00
Jonathan Westhues aedd91735f Text window was double-buffered, but background was still getting
erased before redraw, which caused a bit of flicker on show. And
hide debug prints in solver.

[git-p4: depot-paths = "//depot/solvespace/": change = 1693]
2008-04-27 01:31:56 -08:00
Jonathan Westhues 49ec1346d7 Add the first `derived' group, that generates entities based on
other entities. This requires a new point type, for a point that's
defined as a transformation of some other point. All works nicely,
I think. There's ugliness because entities are no longer guaranteed
to have a parent request.

Also speed up display of the text window, by caching brushes
instead of recreating for each character (!), and add a bit more
user interface in the text window.

[git-p4: depot-paths = "//depot/solvespace/": change = 1692]
2008-04-27 01:03:01 -08:00
Jonathan Westhues bfc7109e0c Standardize the behaviour of constraints, by assigning them a
workplane: a free constraint works in three-space (e.g. true
distance), and a constraint in a workplane works in that plane
(e.g. projected distance). And make the solver go automatically,
though solver itself has lots of pieces missing.

[git-p4: depot-paths = "//depot/solvespace/": change = 1691]
2008-04-26 21:00:12 -08:00
Jonathan Westhues 15476d4732 A great renaming. 2d coordinate systems are now called workplanes,
and the associated entities are now just points.

[git-p4: depot-paths = "//depot/solvespace/": change = 1690]
2008-04-26 19:26:27 -08:00
Jonathan Westhues 5bc3738ec4 Add cubics, and tweak mouse handling code.
[git-p4: depot-paths = "//depot/solvespace/": change = 1689]
2008-04-25 04:07:17 -08:00
Jonathan Westhues c934737d9e Add a function to combine vertices while tesselating the polygon,
so that OpenGL can fill self-intersecting polygons.

[git-p4: depot-paths = "//depot/solvespace/": change = 1688]
2008-04-25 02:11:29 -08:00
Jonathan Westhues ebdef1818c Simplify the way that the active csys is handled, and default to
locked on to the XY plane. And simplify the handling of colors in
the text window: identify them by a character, not an integer ID,
since the character is easier to remember.

[git-p4: depot-paths = "//depot/solvespace/": change = 1687]
2008-04-25 00:26:15 -08:00
Jonathan Westhues a7cec38656 Add code to assemble the piecewise linear segments in a group into
a polygon, and to fill that polygon.

[git-p4: depot-paths = "//depot/solvespace/": change = 1686]
2008-04-24 23:04:09 -08:00
Jonathan Westhues 1331457928 Rough file/save for SolveSpace; that's all done from a single
table, relatively small code size. No user interface for it,
though.

[git-p4: depot-paths = "//depot/solvespace/": change = 1685]
2008-04-23 22:22:16 -08:00
Jonathan Westhues 80dd0fc029 Draw the horizontal/vertical markers in the direction of the actual
basis vectors, not in the direction of the line connecting the
points.

[git-p4: depot-paths = "//depot/solvespace/": change = 1684]
2008-04-22 23:46:24 -08:00
Jonathan Westhues a8001adf33 Add horizontal and vertical constraints. Those have their own 2d/3d
issues, when the points are not all in the same coordinate system.
All painful, of course. Also add continuous line drawing, and
auto-constraining of line segments as I draw.

[git-p4: depot-paths = "//depot/solvespace/": change = 1683]
2008-04-22 23:29:19 -08:00
Jonathan Westhues 1bf7e3deaf Add an ExprVector class, for a 3-vector whose members are
expressions. That simplifies a few things considerably. And some
little UI tweaks.

[git-p4: depot-paths = "//depot/solvespace/": change = 1682]
2008-04-22 05:14:15 -08:00
Jonathan Westhues fa71238def Some graphics tweaks, to the order in which stuff gets drawn, to
determine what goes in front (e.g. put a drawn line in front of the
reference plane, even if the z order would want the opposite), and
some tweaks to the mouse behaviour, and a function to modify
constraints like dimensions so that the are initially satisfied.

[git-p4: depot-paths = "//depot/solvespace/": change = 1681]
2008-04-22 02:53:42 -08:00
Jonathan Westhues 1f77024771 Add an equal length constraint for line segments.
[git-p4: depot-paths = "//depot/solvespace/": change = 1680]
2008-04-21 21:00:49 -08:00
Jonathan Westhues 9b1b255e85 Now I can display the edit control in the graphics window, and edit
the label associated with a constraint. And that even works,
changes the length of the line.

[git-p4: depot-paths = "//depot/solvespace/": change = 1678]
2008-04-21 02:12:04 -08:00
Jonathan Westhues 2926fa95d9 Start to add some constraint stuff. I now have point-coincident,
and point-in-plane. These work, but the equation is still stupid,
solving everything at once and not substituting trivial equations.

[git-p4: depot-paths = "//depot/solvespace/": change = 1677]
2008-04-21 00:16:38 -08:00
Jonathan Westhues 7220f998fc Rename the variables for the linear system to solve, for a bit more
clarity.

[git-p4: depot-paths = "//depot/solvespace/": change = 1676]
2008-04-20 17:26:36 -08:00
Jonathan Westhues b78b10ac1a Ultra-rough beginnings of a solver. Write the constraint equations,
take the partial derivatives, and run the Newton's method. This
seems to sort of work with a single distance constraint.

[git-p4: depot-paths = "//depot/solvespace/": change = 1675]
2008-04-20 03:35:10 -08:00
Jonathan Westhues ed50632610 Rename some functions in Entity; those specific to a given type all
start with some prefix.

[git-p4: depot-paths = "//depot/solvespace/": change = 1674]
2008-04-19 03:44:44 -08:00
Jonathan Westhues cc03fe40aa Big structural change; eliminate the Point type in SolveSpace. The
points are now entities like any others; so a line segment request
will generate three entities, the line segment and its endpoints. I
think that's cleaner.

When I do step and repeats (and imports, and other similar), I'll
need a consistent way to assign those entity ids. That assignment
must not change if the sketch is edited. I don't have a clean way
to do that; best thought right now is to keep a record of what maps
have been used previously, and not pick a new map as long as it's
possible to use one that was used previously.

This all means that more crap gets pushed in to the Entity
structure, so that they can keep track of what solver variables
define them. Still seems better, though. I'm closer to ready
to start solving.

[git-p4: depot-paths = "//depot/solvespace/": change = 1673]
2008-04-19 03:09:47 -08:00
Jonathan Westhues 0d3217c0df Rename some stuff in the IdList again. Rough in the file save
stuff, though no file load stuff, and perhaps this can all be made
to work from a table somehow. Move the quaternion stuff into its
own class, and add a fancy animated view when you orient onto a
csys.

[git-p4: depot-paths = "//depot/solvespace/": change = 1672]
2008-04-18 03:11:48 -08:00
Jonathan Westhues c097fea4f3 Make the tag (for items in an idlist) a member of the templated
data structure, and thus get rid of a level of struct.

[git-p4: depot-paths = "//depot/solvespace/": change = 1671]
2008-04-17 23:21:17 -08:00
Jonathan Westhues 2f4a3917c5 Add functions to deep-copy Exprs, for those generated from user
expressions that we wish to keep around. And make the 2d coordinate
system (that causes points to generate 2 unknowns, not 3) an
attribute of the request, not the group, and add user interface to
change that.

[git-p4: depot-paths = "//depot/solvespace/": change = 1670]
2008-04-17 23:06:37 -08:00
Jonathan Westhues 1fa7865024 Add a little parser, that takes a string and generates and Expr *
syntax tree. That's what I'll used for entered dimensions, and
algebraic constraints and such. Needs to be extended to handle
stuff like points and entities, but I think that it can be.

[git-p4: depot-paths = "//depot/solvespace/": change = 1669]
2008-04-16 22:42:32 -08:00