RingRosey|v1.2| two-radius ring segment helper
Posted: Fri Apr 21, 2017 11:55 pm
I was curious and in need of a method of getting the 4 points of a segment of a ring,
I decided to share simply out of 'why not' and also to as always take advice/critic on code to better the snippets.
Github RingRosey
The goals were simple : allow one to specify outer and inner rings and number of 'radii steps' between the two and the start and size of the segment(s) projected.
ArcSegment(cx,cy,radius1,radius2,start,arc)
cx , cy : The center of the ring
radius1 : The outer radius (total radius) of the ring.
radius2 : The inner radius to use
start : the starting angle to use, in degrees.
arc : the segment size to use, in degrees.
RETURNS :
four points x1,y1 , x2,y2 , x3,y3 , x4,y4 of the segment
ArcSegments(x,y,outer_radius,inner_radius,steps,arc)
cx , cy : The center of the ring
outer_radius : The outer radius (total radius) of the ring.
inner_radius : The inner radius to use
steps : attempts to create this many rings from the inner to outer radius, *has some issues with high precision floats it seems.
arc : the segment size to use, in degrees.
RETURNS :
A 3-dimensioned table containing the rings which in turn contain segments which contain respective 4 points per segment.
Change log :
v1 -
initial release
v1.1 -
Fixed the step argument in ArcSegments to properly translate to number of rings to make though it has some issues with high precision floats it seems.
v1.2 -
Fixed ArcSegments() not properly setting each arcs end radius.
Also Fixed issue where ArcSegments() created one more arc than it should have causing an extra overlapping set of segments on first set.
I decided to share simply out of 'why not' and also to as always take advice/critic on code to better the snippets.
Github RingRosey
The goals were simple : allow one to specify outer and inner rings and number of 'radii steps' between the two and the start and size of the segment(s) projected.
ArcSegment(cx,cy,radius1,radius2,start,arc)
cx , cy : The center of the ring
radius1 : The outer radius (total radius) of the ring.
radius2 : The inner radius to use
start : the starting angle to use, in degrees.
arc : the segment size to use, in degrees.
RETURNS :
four points x1,y1 , x2,y2 , x3,y3 , x4,y4 of the segment
ArcSegments(x,y,outer_radius,inner_radius,steps,arc)
cx , cy : The center of the ring
outer_radius : The outer radius (total radius) of the ring.
inner_radius : The inner radius to use
steps : attempts to create this many rings from the inner to outer radius, *has some issues with high precision floats it seems.
arc : the segment size to use, in degrees.
RETURNS :
A 3-dimensioned table containing the rings which in turn contain segments which contain respective 4 points per segment.
Change log :
v1 -
initial release
v1.1 -
Fixed the step argument in ArcSegments to properly translate to number of rings to make though it has some issues with high precision floats it seems.
v1.2 -
Fixed ArcSegments() not properly setting each arcs end radius.
Also Fixed issue where ArcSegments() created one more arc than it should have causing an extra overlapping set of segments on first set.