# Difference between revisions of "Math bits"

(→The nearest point on an ellipse to a given point: typo) |
(Added method to draw tan1_2p) |
||

Line 38: | Line 38: | ||

\frac{d^{2}(s^{2})}{dt^{2}}=\gamma(1-2u^{2})+\alpha u+\frac{\beta^{2}u}{\alpha-\gamma u}>0 | \frac{d^{2}(s^{2})}{dt^{2}}=\gamma(1-2u^{2})+\alpha u+\frac{\beta^{2}u}{\alpha-\gamma u}>0 | ||

</math> | </math> | ||

+ | |||

+ | |||

+ | == Given a circle, construct a tangent circle passing two given points== | ||

+ | Given a circle, the path of center of all tangent circles passing a given point is either an ellipse or a hyperbola. A quadratic form of either ellipse or hyperbola is constructed for each of the given points, and the center of the circle to be constructed in on the intersections of these two quadratic forms. After locating of the circle center, the radius is found by the distance from either of the given points to the center. | ||

+ | |||

+ | LibreCAD has a powerful general quadratic form framework to ease the construction of such quadratic forms and location of intersections between two quadratic forms. | ||

== modular function in LibreCAD == | == modular function in LibreCAD == |

## Revision as of 22:20, 24 June 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*,

γ^{2}*u*^{4} − 2αγ*u*^{3} + (α^{2} + β^{2} − γ^{2})*u*^{2} + 2αγ*u* − α^{2} = 0

where α = 2*a**x*, β = 2*b**y*, and γ = 2(*a*^{2} − *b*^{2}).

For all solutions from the quartic equation, the minimum distance point is identified by the convex condition,

## Given a circle, construct a tangent circle passing two given points

Given a circle, the path of center of all tangent circles passing a given point is either an ellipse or a hyperbola. A quadratic form of either ellipse or hyperbola is constructed for each of the given points, and the center of the circle to be constructed in on the intersections of these two quadratic forms. After locating of the circle center, the radius is found by the distance from either of the given points to the center.

LibreCAD has a powerful general quadratic form framework to ease the construction of such quadratic forms and location of intersections between two quadratic forms.

## 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,