dcowden / cadquery

CadQuery-- a parametric cad script framework
Other
432 stars 56 forks source link

Add polarLine and polarLineTo methods #292

Closed johnbeard closed 6 years ago

johnbeard commented 6 years ago

Useful for defining lines when you know the length and angle, rather than the Cartesian co-ordinates.

Based on issue #291

coveralls commented 6 years ago

Coverage Status

Coverage increased (+0.03%) to 92.28% when pulling 7a3a56132e777dfe4fe1c23b7b2562cc82d77f0a on johnbeard:polarline into 6251ec08366efebe64f8e73a424d174b414e17f9 on dcowden:master.

AppVeyorBot commented 6 years ago

:white_check_mark: Build cadquery 1.0.73 completed (commit https://github.com/dcowden/cadquery/commit/9b4ee30572 by @johnbeard)

codecov-io commented 6 years ago

Codecov Report

Merging #292 into master will increase coverage by 0.02%. The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #292      +/-   ##
==========================================
+ Coverage   92.79%   92.82%   +0.02%     
==========================================
  Files          10       10              
  Lines        2207     2215       +8     
==========================================
+ Hits         2048     2056       +8     
  Misses        159      159
Impacted Files Coverage Δ
cadquery/cq.py 94.33% <100%> (+0.06%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 6251ec0...7a3a561. Read the comment docs.

johnbeard commented 6 years ago

Something else which occurred to me is would it be useful to have polarLineToX and polarLineToY functions, which extend a line at a given angle from the current point to the given ordinate/mantissa? For example, go from here at an angle of 30 degrees until you hit x=40. It would make things like set-backs quite straightforward.

The questions then would be:

dcowden commented 6 years ago

@johnbeard thanks for the contribution!

This looks great to me. Would you like to merge it as is, or do you want to also add the other versions you are contemplating above first?

johnbeard commented 6 years ago

I don't really mind, it can a follow-up PR if you want.

I would like to know what you'd like to do on error (e.g. parallel line) or a "reverse" situation before I do the toX and toY variants (and only if you agree they are desirable).

johnbeard commented 6 years ago

Hmm, looking at it, the neatest way to do toX and toY probably would be using Vector.projectToLine somehow. I'd rather not do too much vector maths when we have a full-scale geometry kernel to do it for us.

Perhaps just merge this and I'll have a think about the other methods.

dcowden commented 6 years ago

@johnbeard i tend to agree that proceeding as-is is best. I think polarLineToX and polarLineToY would be rarely used. and then the error cases you'd be describing would be rare within those cases.

Unrelated, i think what would be really cool is ability to draw lines and have them trimmed when they intersect others. that's a baby version of constrtraint solving.

What I really want is a 2d sketch solver, so that instead of doing the math on a piece of paper, you can actually create the sketch the same way you would in Solidworks or FreeCAD -- in which you link the geometry to contraints and let it solve.

jmwright commented 6 years ago

@johnbeard @dcowden It sounds like this is ready to merge. Is that correct?

dcowden commented 6 years ago

I think so

jmwright commented 6 years ago

Thanks for the contribution @johnbeard