js-dxf icon indicating copy to clipboard operation
js-dxf copied to clipboard

find end of shape

Open ashleycoker opened this issue 3 years ago • 4 comments

i am trying to find the end of an arc so that I can draw the following shape:

image

it is an arc with an inside arc obviously then closed with two end lines. is it possible? fyi: the resulting arcs should fit inside a parent circle...

ashleycoker avatar Aug 28 '22 09:08 ashleycoker

Hi,

What do you mean by end of the arc is it the coordinates of the start and the end of the arc.

tarikjabiri avatar Aug 28 '22 10:08 tarikjabiri

Yes, when you draw an arc (or a line,shape etc), for it to return the coordinates of the end position, so that you can start your next shape from there.

Ashley Coker, CEO w: AskSlate.com e: @.*** m: +44 77382 64519 Unit 7, Fosters Business Park, Old School Road, Hook, Hampshire (Company No. 06898498)

On Sun, Aug 28, 2022 at 11:20 AM EL JABIRI Tarik @.***> wrote:

Hi,

What do you mean by end of the arc is it the coordinates of the start and the end of the arc.

— Reply to this email directly, view it on GitHub https://github.com/ognjen-petrovic/js-dxf/issues/87#issuecomment-1229426293, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAG2S3DRFLCK37KJIFQWSSTV3M4PBANCNFSM572YIIBA . You are receiving this because you authored the thread.Message ID: @.***>

ashleycoker avatar Aug 28 '22 10:08 ashleycoker

Ok

Note that dxf-writer can't do that for you. So you have to keep track of things like that for yourself. The coordinates of the start and end of the arc are simple to get. Ex: Consider an arc defined like this:

  • cx : x coordinate of the center.
  • cy : y coordinate of the center.
  • r: the radius.
  • sa: start angle in radians
  • ea: end angle in radians
// Coordinate of the start
const xstart = cx + r * Math.cos(sa);
const ystart = cy + r * Math.sin(sa);
// Coordinate of the end
const xend = cx + r * Math.cos(ea);
const yend = cy + r * Math.sin(ea);

tarikjabiri avatar Aug 28 '22 10:08 tarikjabiri

It seems that this works for the start point but not the end point? If I draw a line between the two end points it seems further around the circle that I would expect. The start line works. Any pointers?

[image: Capture.PNG]

Ashley Coker, CEO w: AskSlate.com e: @.*** m: +44 77382 64519 Unit 7, Fosters Business Park, Old School Road, Hook, Hampshire (Company No. 06898498)

On Sun, Aug 28, 2022 at 11:56 AM EL JABIRI Tarik @.***> wrote:

Ok

Note that dxf-writer can't do that for you. So you have to keep track of things like that for yourself. The coordinates of the start and end of the arc are simple to get. Ex: Consider an arc defined like this:

  • cx : x coordinate of the center.
  • cy : y coordinate of the center.
  • r: the radius.
  • sa: start angle
  • ea: endAngle

// Coordinate of the startconst xstart = cx + r * Math.cos(sa);const ystart = cy + r * Math.sin(sa);// Coordinate of the endconst xend = cx + r * Math.cos(ea);const yend = cy + r * Math.sin(ea);

— Reply to this email directly, view it on GitHub https://github.com/ognjen-petrovic/js-dxf/issues/87#issuecomment-1229432162, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAG2S3ANAH4QDEBM7VT2L7DV3NAVRANCNFSM572YIIBA . You are receiving this because you authored the thread.Message ID: @.***>

ashleycoker avatar Aug 28 '22 14:08 ashleycoker