2 ms·
Ah sure, I was thinking quite loosely about 'constraints'. I think you can get pretty far without a solver, with a dependency order in a procedural language lik
by OJFord 6y ago
Ah sure, I was thinking quite loosely about 'constraints'. I think you can get pretty far without a solver, with a dependency order in a procedural language like python. Of course it's not as expressive, but I think it goes a long way, and just isn't possible or at least wouldn't be natural in GUI CAD.
e.g. Scripted CAD pseudocode:
x = param('length')
y = param('width')
z = 2*x + y
base = rect(x, y)
box = base.extrude(z)
radius = y/2 if y < x else x/2
cutout = circle(radius=radius, centre=(radius+base.x, radius+base.y)).extrude(z)
obj = box - cutout
The circle cutout inherently has tangent constraints on the sides of the box, without needing library support or a solver.
I realise there are limits, I just think you could do a lot without hitting them, and when you do.. you're just programming, find a constraint solver to use.
- phkahler 6y agoMake a triangle with side lengths 7,8, and 9. Also, one doesnt usually just find a constraint solver to use. You'll want a geometric constraint solver which will be built on top of a non-linear algebraic constraint solver. It really needs to be integrated into the CAD system.
- OJFord 6y ago> Make a triangle with side lengths 7,8, and 9. p, q, r = params("side1", "side2", "side3") pq = arccos((p^2+q^2-r^2)/(2*p*q)) pr = # ... similar qr = # ... similar assert pq + pr + qr == 360, "Side lengths invalid" pside = line((0,0), (p,0)) xy_qr = (r*cos(180-pr), r*sin(180-pr)) qside = line((p,0), xy_qr) rside = line(xy_qr, (0,0)) triangle = sketch(pside, qside, rside) Or whatever this fictional API is to look like. Obviously to do generic constraint solving, you need a generic constraint solver. My point is that if you have fixed known constraints, and a programming language, you can just compute what you want explicitly.