Yash Chauhan
Yash Chauhan

Reputation: 90

How to calculate start angle and end angle in 3D ARC for DXF file?

Not sure if this is the right place to ask to this question, but I can see so many DXF queries are resolved here.

I have three 3D points (P1 <x1,y1,z1> ; P2 <x2,y2,z2> ; P3 <x3,y3,z3> ) with which I have to generate an 3D ARC and store it in DXF format. So far I am able to generate coordinates for Center (Code : 10,20,30 ), Radius (Code : 40), Extrusion Vector (Code: 210, 220, 230). But not able to find or develop mathematics for start angle and end angle for arc (Code: 50, 51).

Please help me to understand the mathematics behind generating Start and End Angle for ARC.

Upvotes: 0

Views: 777

Answers (1)

Lee Mac
Lee Mac

Reputation: 16015

The start and end angles for an ARC entity (DXF groups 50 & 51 respectively) are defined in degrees measured anticlockwise from the x-axis of the Object Coordinate System (OCS) of the arc.

The OCS is used to define a coordinate system for planar entities and is itself defined by applying the Arbitrary Axis Algorithm to the normal/extrusion vector (DXF group 210) of the entity.

Given an extrusion vector N = (Nx, Ny, Nz) and the World Coordinate System (WCS) axis vectors:

Wx = (1, 0, 0)
Wy = (0, 1, 0)
Wz = (0, 0, 1)

The OCS axis vectors (Ox, Oy, Oz) are defined in the following way (where ^ is the cross product):

if abs(Nx) < 1/64 and abs(Ny) < 1/64 then
    Ox = Wy ^ N
else
    Ox = Wz ^ N
end if
Oy = N ^ Ox
Oz = N

On calculating Ox, the start angle will then be the angle between the vectors defined by the centre of the arc + Ox, and the centre + the first point of the arc. Such angle could be calculated using the dot product of these two vectors.

Upvotes: 3

Related Questions