From 28563b6cacb6a7c0c4425e56c40e3f19c6d58d56 Mon Sep 17 00:00:00 2001 From: Jacob Bayless Date: Sun, 28 May 2023 18:37:12 -0700 Subject: [PATCH 1/2] Alpha implementation of roll-type lattice --- lattice2PolarArray2.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lattice2PolarArray2.py b/lattice2PolarArray2.py index decd553..89c9be7 100644 --- a/lattice2PolarArray2.py +++ b/lattice2PolarArray2.py @@ -71,7 +71,7 @@ def derivedInit(self,selfobj): selfobj.UseArcRange = ['ignore', 'as Span', 'as Step'] selfobj.addProperty('App::PropertyBool', 'UseArcRadius', "Polar Array", "If True, and attachment mode is concentric, supporting arc's radius is used as array radius.") selfobj.addProperty('App::PropertyEnumeration','OrientMode',"Polar Array","Orientation of placements. Zero - aligns with origin. Static - aligns with self placement.") - selfobj.OrientMode = ['Zero', 'Static', 'Radial', 'Vortex', 'Centrifuge', 'Launchpad', 'Dominoes'] + selfobj.OrientMode = ['Zero', 'Static', 'Radial', 'Vortex', 'Centrifuge', 'Launchpad', 'Dominoes', 'Roll'] selfobj.OrientMode = 'Radial' selfobj.addProperty('App::PropertyBool', 'Reverse', "Polar Array", "Reverses array direction.") selfobj.addProperty('App::PropertyBool', 'FlipX', "Polar Array", "Reverses x axis of every placement.") @@ -158,7 +158,7 @@ def derivedExecute(self,selfobj): V( ), V(-1, 0, 0) )) - elif selfobj.OrientMode == 'Launchpad': + elif selfobj.OrientMode == 'Launchpad' or selfobj.OrientMode == "Roll": baseplm = App.Placement(V(), App.Rotation( V( 0, 0, 1), V( ), @@ -191,7 +191,13 @@ def derivedExecute(self,selfobj): output = [] # list of placements for ang in values: localrot = App.Rotation(App.Vector(0,0,1), ang * mm + angleplus) - localtransl = localrot.multVec(App.Vector(radius,0,0)) + if selfobj.OrientMode == "Roll": + if on_arc: + localtransl = localrot.multVec(App.Vector(radius, -radius*(ang - 90.0)*math.pi/180.0, 0)) + else: + localtransl = localrot.multVec(App.Vector(radius, -radius*ang*math.pi/180.0, 0)) + else: + localtransl = localrot.multVec(App.Vector(radius,0,0)) localplm = App.Placement(localtransl, localrot) resultplm = localplm.multiply(baseplm) if is_zero: From 3b0a3ed24c92e697b499c5b629b699c24d5f4cbb Mon Sep 17 00:00:00 2001 From: Jacob Bayless Date: Wed, 31 May 2023 17:31:00 -0700 Subject: [PATCH 2/2] Fixed involute array centering for arbitrary arc angles --- lattice2PolarArray2.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lattice2PolarArray2.py b/lattice2PolarArray2.py index 89c9be7..2e2cea4 100644 --- a/lattice2PolarArray2.py +++ b/lattice2PolarArray2.py @@ -192,10 +192,9 @@ def derivedExecute(self,selfobj): for ang in values: localrot = App.Rotation(App.Vector(0,0,1), ang * mm + angleplus) if selfobj.OrientMode == "Roll": - if on_arc: - localtransl = localrot.multVec(App.Vector(radius, -radius*(ang - 90.0)*math.pi/180.0, 0)) - else: - localtransl = localrot.multVec(App.Vector(radius, -radius*ang*math.pi/180.0, 0)) + localtransl = localrot.multVec(App.Vector(radius, + -radius*((ang - 0.5*(max(values) - min(values)))*math.pi/180.0), + 0)) else: localtransl = localrot.multVec(App.Vector(radius,0,0)) localplm = App.Placement(localtransl, localrot)