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.
RingRosey|v1.2| two-radius ring segment helper
- ArchAngel075
- Party member
- Posts: 319
- Joined: Mon Jun 24, 2013 5:16 am
RingRosey|v1.2| two-radius ring segment helper
Last edited by ArchAngel075 on Fri May 05, 2017 9:18 am, edited 2 times in total.
- ArchAngel075
- Party member
- Posts: 319
- Joined: Mon Jun 24, 2013 5:16 am
Re: RingRosey|v1.1| two-radius ring segment helper
updated with fixes to steps argument, I was unhappy with its inconsistent behavior.
- ArchAngel075
- Party member
- Posts: 319
- Joined: Mon Jun 24, 2013 5:16 am
Re: RingRosey|v1.2| two-radius ring segment helper
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.
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
Nice, but very specific using, and vector graphic not so fast they possible :<
Also, you can use standart graphic transform:
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()
Science and violence
- ArchAngel075
- Party member
- Posts: 319
- Joined: Mon Jun 24, 2013 5:16 am
Re: RingRosey|v1.2| two-radius ring segment helper
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.arcHDPLocust 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()
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
Who is online
Users browsing this forum: No registered users and 0 guests