Skip to content
This repository has been archived by the owner on Oct 7, 2020. It is now read-only.

Ring pad support inspired by wuerth electronics smd mounting hardware #351

Merged
merged 39 commits into from
Oct 5, 2019

Conversation

poeschlr
Copy link
Collaborator

@poeschlr poeschlr commented May 9, 2019

Note this is work in progress. For ringed pads to work i will also need to implement:

  • polar coordinate support for Vector2d including rotating it around a given point
  • arcs with more options to define them
    • center, start, angle (original)
    • center, mid, angle
    • center, start, end, long_way (long way parameter needed as every two points plus center combination has two valid arcs. Note that the end point can be off the arc which will result in a warning and the radius from center to end is ignored only the angle is used.)
    • start, mid, end (prepared but not implemented)
  • split geometry stuff from kicad types (In part to avoid circular references)
    • translate and rotate support for geometric primitives
    • copy function and init from type(self)
    • cut with lines
      • missing for circle
  • polar array (If i get time)

I noticed that the serializer class can not really deal with inheritance. But i do not think i will have time to look into this.

@codeclimate
Copy link

codeclimate bot commented May 9, 2019

Code Climate has analyzed commit 6385473 and detected 85 issues on this pull request.

Here's the issue category breakdown:

Category Count
Complexity 18
Duplication 66
Style 1

View more on Code Climate.

@poeschlr poeschlr force-pushed the ring_pad branch 3 times, most recently from 010fc96 to 2a4ea5b Compare May 10, 2019 14:46
@poeschlr poeschlr force-pushed the ring_pad branch 3 times, most recently from 4808380 to 7f45734 Compare May 12, 2019 07:35
@poeschlr poeschlr force-pushed the ring_pad branch 2 times, most recently from c543fc5 to 26ce593 Compare May 12, 2019 16:53
@poeschlr
Copy link
Collaborator Author

poeschlr commented Sep 1, 2019

@pointhi do you have any feedback? Or simply no time?

@pointhi
Copy link
Owner

pointhi commented Oct 5, 2019

I did a rough check and think it should be ok. I would suggest to not rely on Multiple Inheritance to much, because it makes code harder to read and more error prone

@pointhi pointhi merged commit a1ba4a9 into pointhi:master Oct 5, 2019
Copy link
Collaborator

@cpresser cpresser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some points that cannot be tied to a specific line:

  • Can the file KicadModTree/nodes/specialized/Rotation.py and related tests be removed? I don't see what it does, its not used at all. And based on the name it seems to be redundant.
  • I did not do a in depth review of the new tests. Just a quick look around.
  • geometry_utils.py is quite a lot of stuff. I read the whole thing, but did only verify a few of the geometric heavy functions

Some files I did not review yet:

  • The actual generator script and the .yaml file
  • RingPad.py

* *origin* (``Vector2D``)
origin point for the rotation. default: (0, 0)
* *use_degrees* (``boolean``)
rotation angle is given in degrees. default:True
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume the other option is 'radians', but thats not mentioned anywhere.
This also applies to the rotate() function in Vector2D

Comment on lines +262 to +277
def to_homogeneous(self):
r""" Get homogeneous representation
"""

return Vector3D(self.x, self.y, 1)

@staticmethod
def from_homogeneous(source):
r""" Recover 2d vector from its homogeneous representation

:params:
* *source* (``Vector3D``)
3d homogeneous representation
"""

return Vector2D(source.x/source.z, source.y/source.z)
Copy link
Collaborator

@cpresser cpresser Oct 5, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be unused.
Nevermind, I found where its used.

Comment on lines +352 to +364
def cross_product(self, other):
other = Vector3D.__arithmetic_parse(other)

return Vector3D({
'x': self.y*other.z - self.z*other.y,
'y': self.z*other.x - self.x*other.z,
'z': self.x*other.y - self.y*other.x})

def dot_product(self, other):
other = Vector3D.__arithmetic_parse(other)

return self.x*other.x + self.y*other.y + self.z*other.z

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above: this seems to be unused.
Can you give an example use-case for those functions?

def _initType(self, **kwargs):
self.type = kwargs['type']
if self.type not in Text._TYPES:
raise ValueError('Illegal type selected for text field.')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The documentation for type should get updated as well.

  • Specify that the argument is mandatory (I assume this will fail for None)
  • Specify the 3 options for the type

i += 1

file_handler = KicadFileHandler(kicad_mod)
file_handler.writeFile('test.kicad_mod')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment this line out

alternative to angle
arcs of this form are given as start, end and center
* *angle* (``float``) --
angle of arc
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

specify degrees here

)
self._initAngle(ep_a - sp_a)

if kwargs.get('long_way', False):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

long_way not described as parameter

I would opt to make this a CW/CCW parameter instead.

return (rad_p, ang_p_s)

def _compareAngles(self, a1, a2, tolerance=1e-7):
r""" compare which of the two angles given in the local coordinate system
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

compare what?

Comment on lines +398 to +405
def _toLocalCoordinates(self, point):
rad_s, ang_s = self.start_pos.to_polar(origin=self.center_pos)
rad_p, ang_p = Vector2D(point).to_polar(origin=self.center_pos)

ang_p_s = (ang_p - ang_s) % 360
if self.angle < 0:
ang_p_s -= 360
return (rad_p, ang_p_s)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename to _toLocalPolarCoordinates

return self

def cut(self, *other):
raise NotImplemented("cut for circles not yet implemented")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

even if its not implemented, you could call the cut function of the base class. Once its implemented you only need to change one code location.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants