tarikjabiri / js-dxf

JavaScript DXF writer
MIT License
179 stars 76 forks source link

find end of shape #87

Closed ashleycoker closed 1 year ago

ashleycoker commented 2 years ago

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...

tarikjabiri commented 2 years ago

Hi,

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

ashleycoker commented 2 years ago

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: @.***>

tarikjabiri commented 2 years ago

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:

// 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);
ashleycoker commented 2 years ago

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: @.***>