MCPcopy Create free account
hub / github.com/MeshInspector/MeshLib / calcCircleCenter

Function calcCircleCenter

source/MRVoxels/MRToolPath.cpp:44–61  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

42}
43
44bool calcCircleCenter( const Vector2f& p0, const Vector2f& p1, const Vector2f& p2, Vector2f& center )
45{
46 const auto dif1 = p1 - p0;
47 const auto dif2 = p2 - p0;
48
49 const auto proj1 = dot( dif1, p0 + p1 );
50 const auto proj2 = dot( dif2, p0 + p2 );
51 const auto det = cross( dif1, p2 - p1 ) * 2;
52
53 if ( fabs( det ) < 1e-10 )
54 return false;
55
56 // calc center coords
57 center.x = ( dif2.y * proj1 - dif1.y * proj2 ) / det;
58 center.y = ( dif1.x * proj2 - dif2.x * proj1 ) / det;
59
60 return true;
61}
62
63// get coordinate along specified axis
64float coord( const GCommand& command, Axis axis )

Callers 1

Calls 2

dotFunction · 0.50
crossFunction · 0.50

Tested by

no test coverage detected