Page 1 of 1

RingRosey|v1.2| two-radius ring segment helper

Posted: Fri Apr 21, 2017 11:55 pm
by ArchAngel075
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.

Re: RingRosey|v1.1| two-radius ring segment helper

Posted: Sat Apr 22, 2017 8:13 am
by ArchAngel075
updated with fixes to steps argument, I was unhappy with its inconsistent behavior.

Re: RingRosey|v1.2| two-radius ring segment helper

Posted: Fri May 05, 2017 9:18 am
by ArchAngel075
Updated v1.2 :
Updated with a major fix, Perhaps i was too tired when writing it but noticed that arc segments were not using correct end radius (they would use main outer radius allways, resulting in segments overlapping and incorrect sizes)
Also Fixed issue where ArcSegments() created one more arc than it should have causing an extra overlapping set of segments on first set.

Re: RingRosey|v1.2| two-radius ring segment helper

Posted: Fri May 05, 2017 12:52 pm
by HDPLocust
Nice, but very specific using, and vector graphic not so fast they possible :<
Also, you can use standart graphic transform:

Code: Select all

love.grapgics.push()
love.graphics.scale(2, 0.5)
love.graphics.rotate(3.14)
love.graphics.arc(...)
love.graphics.pop()

Re: RingRosey|v1.2| two-radius ring segment helper

Posted: Thu May 11, 2017 1:06 am
by ArchAngel075
HDPLocust wrote: Fri May 05, 2017 12:52 pm Nice, but very specific using, and vector graphic not so fast they possible :<
Also, you can use standart graphic transform:

Code: Select all

love.grapgics.push()
love.graphics.scale(2, 0.5)
love.graphics.rotate(3.14)
love.graphics.arc(...)
love.graphics.pop()
It is specific but that is due to it being made for a project of mine and I needed more control over the arc's than love.graphics.arc

Also love.graphics.arc can not create arcs with 2 radii (inner radius and outer radius) - Donuts are not possible unless more is done - whereas this attempts to create the coordinates directly using equation of a circle and some loops.
Also love.graphics.arc draws an arc but any information about that arc is not obtainable - With RingRosey we get polygons with points that we can render easily and work with - nothing stops you from using 0 as the inner radius to mimic love.graphics.arc with points we can work with elsewhere.
I needed to make this for my own use and felt that maybe others would find some use for it too if they needed something similar