We have moved to https://dokuwiki.librecad.org/
Lots of content was already moved to the new wiki, but there is still work to do. If you want to contribute, please register a new account at https://dokuwiki.librecad.org/
This wiki will be kept for a while to keep search engine results valid. Moved sites may be deleted here in future.
Difference between revisions of "Math bits"
(→modular function in LibreCAD) |
(→modular function in LibreCAD) |
||
Line 41: | Line 41: | ||
== modular function in LibreCAD == | == modular function in LibreCAD == | ||
the standard glibc fmod(x, a) is not convenient here, since we need a modular function work the same way for both positive and negative numbers, instead, we use, | the standard glibc fmod(x, a) is not convenient here, since we need a modular function work the same way for both positive and negative numbers, instead, we use, | ||
− | |||
− | |||
<math> | <math> | ||
− | + | remainder(x - \frac{a}{2},a)+\frac{a}{2} | |
− | remainder(x - | + | |
− | + | ||
</math> | </math> |
Revision as of 23:03, 22 April 2012
The nearest point on an ellipse to a given point
An ellipse in the coordinates orientated alone its major and minor axes is given as,
The squared distance from a point on ellipse to a given point(x,y),
The stationary points at the zero points of its first order derivative of t,
This stationary condition is a quartic equation of cos t. With variable change u = cos t,
γ2u4 − 2αγu3 + (α2 + β2 − γ2)u2 + 2αγu − α2 = 0
where α = 2ax, β = 2by, and γ = 2(a2 − b2).
For all solutions from the quartic equation, the minimum distance point is identified the convex condition,
modular function in LibreCAD
the standard glibc fmod(x, a) is not convenient here, since we need a modular function work the same way for both positive and negative numbers, instead, we use,