Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow polar coordinates for pattern generators #14

Open
sf-issues opened this issue Oct 3, 2012 · 0 comments
Open

Allow polar coordinates for pattern generators #14

sf-issues opened this issue Oct 3, 2012 · 0 comments
Milestone

Comments

@sf-issues
Copy link

Converted from SourceForge issue 3025117, submitted by jbednar
Submit Date: 2010-07-04 17:03 GMT

Stuart Wilson found it useful to be able to place a PatternGenerator at specified (radius,angle) polar coordinates, and modified PatternGenerator to allow this:

 rotation = param\.Number\(default=0\.0,softbounds=\(0\.0,2\*pi\),precedence=0\.40,doc="""
     Angle of polar translation from x,y origin\."""\)

 radius = param\.Number\(default=0\.0,softbounds=\(0\.0,1\.0\),precedence=0\.50,doc="""
     Radius of polar translation from x,y origin\."""\)

 rotate\_around\_square = param\.Boolean\(default=False,doc="""
     Make polar rotation follow a square rather than a circle\."""\)

...

def __create_and_rotate_coordinate_arrays(self, x, y, orientation, rotation, radius, rotate_around_square):
"""
Create pattern matrices from x and y vectors, and rotate
them to the specified orientation.
"""

     \# Polar Coordinate translation added by Stuart
     if rotate\_around\_square==True:
         x\-=round\(cos\(rotation\)\)\*radius
         y\-=round\(sin\(rotation\)\)\*radius
     else:
         x\-=cos\(rotation\)\*radius
         y\-=sin\(rotation\)\*radius

     \# Using this two\-liner requires that x increase from left to
     \# right and y decrease from left to right; I don't think it
     \# can be rewritten in so little code otherwise \- but please
     \# prove me wrong\.

     pattern\_y = subtract\.outer\(cos\(orientation\)\*y, sin \(orientation\)\*x\)
     pattern\_x = add\.outer\(sin\(orientation\)\*y, cos\(orientation\)\*x\)

     return pattern\_x, pattern\_y

Although I can see cases where using polar coordinates would be very useful, I'm not sure that we need to provide it at the PatternGenerator level. (But if anyone disagrees, please generalize the above, put it into PatternGenerator, and let me know that you've done so!

It seems like we could instead provide a simple wrapper PatternGenerator similar to Composite that would accept the polar coordinates, and then internally convert them to Cartesian coordinates to place the wrapped PatternGenerator. Seems like only a few lines to implement that, but because I don't currently have any use for it, I'm filing it as a feature request for someone to pick up if they need it.

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

No branches or pull requests

1 participant