You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
lxqt-config-packaging/lxqt-config-monitor/magnetic_attraction.html

43 lines
3.7 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<html>
<head>
<title>Magnetic attraction algorithm</title>
<meta charset='utf-8'/>
</head>
<body>
<h1>Magnetic attraction algorithm</h1>
<p>The algorithm used to move monitors to the nearest one in “position dialog” is explained here.</p>
<p>Segment equation is used. Lets explain segment equation in order to understand the proccess:</p>
<p>If you have two points, <b>p<sub>0</sub></b>, <b>p<sub>1</sub></b> &in; &reals; <sup>2</sup>, the equation of straight line between <b>p<sub>0</sub></b> and <b>p<sub>1</sub></b> is: </p>
<b>r</b> = <b>v</b> · t + <b>p<sub>0</sub></b>
<p>where <b>v</b> = <b>p<sub>1</sub></b> - <b>p<sub>0</sub></b>, and t &in; [0,1].</p>
<p>Algorithm calculates equation of the segment between monitor centers. Then, it gets intersection points with edges of monitors:</p>
<svg width="343" height="123" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg">
<!-- Created with SVG-edit - http://svg-edit.googlecode.com/ -->
<g>
<title>Layer 1</title>
<rect id="svg<sub>1</sub>" height="89" width="117" y="2.5" x="2.5" stroke-width="5" stroke="#000000" fill="#ffffff"/>
<rect id="svg<sub>2</sub>" height="89" width="117" y="31.5" x="223.5" stroke-width="5" stroke="#000000" fill="#ffffff"/>
<line id="svg_4" y2="77.5" x2="286.5" y1="47.5" x1="59.5" stroke-linecap="null" stroke-linejoin="null" stroke-dasharray="null" stroke-width="5" stroke="#000000" fill="none"/>
<text style="cursor: text;" xml:space="preserve" text-anchor="middle" font-family="serif" font-size="24" id="svg_5" y="50.5" x="53.5" stroke-linecap="null" stroke-linejoin="null" stroke-dasharray="null" stroke-width="0" stroke="#000000" fill="#000000">c_0</text>
<text style="cursor: move;" xml:space="preserve" text-anchor="middle" font-family="serif" font-size="24" id="svg_6" y="70.5" x="288.5" stroke-linecap="null" stroke-linejoin="null" stroke-dasharray="null" stroke-width="0" stroke="#000000" fill="#000000">c_1</text>
<text style="cursor: move;" xml:space="preserve" text-anchor="middle" font-family="serif" font-size="24" id="svg_7" y="30.5" x="120.5" stroke-linecap="null" stroke-linejoin="null" stroke-dasharray="null" stroke-width="0" stroke="#000000" fill="#000000">t_2</text>
<text style="cursor: move;" xml:space="preserve" text-anchor="middle" font-family="serif" font-size="24" id="svg_8" y="35.5" x="191.5" stroke-linecap="null" stroke-linejoin="null" stroke-dasharray="null" stroke-width="0" stroke="#000000" fill="#000000">t_1</text>
<ellipse ry="4" rx="4" id="svg_9" cy="55" cx="119.5" stroke-linecap="null" stroke-linejoin="null" stroke-dasharray="null" stroke-width="5" stroke="#000000" fill="#000000"/>
<ellipse id="svg<sub>1</sub>1" ry="4" rx="4" cy="69" cx="223.5" stroke-linecap="null" stroke-linejoin="null" stroke-dasharray="null" stroke-width="5" stroke="#000000" fill="#000000"/>
</g>
</svg>
<p>If <b>v</b> = <b>c<sub>1</sub></b> - <b>c<sub>0</sub></b>, <b>c<sub>0</sub></b> and <b>c<sub>1</sub></b> are monitors centers, the equation between them is <b>r</b> = <b>v</b> · t + <b>c<sub>0</sub></b>.</p>
<p>where t<sub>1</sub> is the parameter of the mentioned equation to get the intersection point with the c<sub>1</sub> monitor.</p>
<p>where t<sub>2</sub> the parameter with the c<sub>0</sub> monitor.</p>
<p>t<sub>1</sub>, t<sub>2</sub> &in; [0,1].</p>
<p>If t<sub>2</sub>&lt;t<sub>1</sub>, the monitors are separated, otherwise the monitors are overlapped.</p>
<p>With the previous information we get:</p>
<p><b>r<sub>1</sub></b> = <b>v</b>· t<sub>1</sub> + <b>c<sub>0</sub></b></p>
<p><b>r<sub>2</sub></b> = <b>v</b>· t<sub>2</sub> + <b>c<sub>0</sub></b></p>
<p>Iff t<sub>2</sub>&lt;t<sub>1</sub>, c<sub>0</sub> monitor must be moved, and its displacement is provided by <b>r</b> = <b>r<sub>1</sub></b>-<b>r<sub>2</sub></b></p>
</body>
</html>