General's Horse Drinking: Minimizing Segment Sum via Reflection
2019-04-30 13:36
This applet demonstrates the classic 'General's Horse Drinking' optimization problem. Given points A and B on the same side of a line, it uses reflection to find B', the symmetric point of B. The intersection of AB' and the line is point P, minimizing the sum of PA and PB. Dragging P dynamically verifies the minimum at the intersection, illustrating the shortest path principle.
In collections
我的第一个GGB绘本
<?xml version="1.0" encoding="utf-8"?>
<geogebra format="5.0" version="5.0.535.0" app="classic" platform="w" id="1F9A89B8-2C07-4FE0-B7D1-714928A51533" xsi:noNamespaceSchemaLocation="http://www.geogebra.org/ggb.xsd" xmlns="" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >
<gui>
<window width="1280" height="664" />
<perspectives>
<perspective id="tmp">
<panes>
<pane location="" divider="0.628125" orientation="1" />
<pane location="0" divider="0.296875" orientation="1" />
</panes>
<views>
<view id="512" toolbar="0 | 1 501 5 19 , 67 | 2 15 45 18 , 7 37 | 514 3 9 , 13 44 , 47 | 16 51 | 551 550 11 , 20 22 21 23 , 55 56 57 , 12 | 69 | 510 511 , 512 513 | 533 531 , 534 532 , 522 523 , 537 536 , 535 | 521 520 | 36 , 38 49 560 | 571 30 29 570 31 33 | 17 | 540 40 41 42 , 27 28 35 , 6 , 502" visible="false" inframe="false" stylebar="false" location="1,1,1" size="500" window="100,100,600,400" />
<view id="1" visible="true" inframe="false" stylebar="false" location="3,1" size="416" window="100,100,600,400" />
<view id="4" toolbar="0 || 2020 , 2021 , 2022 || 2001 , 2003 , 2002 , 2004 , 2005 || 2040 , 2041 , 2042 , 2044 , 2043" visible="false" inframe="false" stylebar="false" location="1,1" size="300" window="100,100,600,400" />
<view id="2" visible="true" inframe="false" stylebar="false" location="3,3" size="380" window="100,100,600,400" />
<view id="8" toolbar="1001 | 1002 | 1003 || 1005 | 1004 || 1006 | 1007 | 1010 || 1008 | 1009 || 6" visible="false" inframe="false" stylebar="false" location="1,3" size="300" window="100,100,600,400" />
<view id="4097" visible="false" inframe="false" stylebar="true" location="1,1" size="233" window="100,100,700,550" />
<view id="16" visible="true" inframe="false" stylebar="false" location="1" size="468" window="50,50,500,500" />
<view id="32" visible="false" inframe="false" stylebar="true" location="1" size="300" window="50,50,500,500" />
<view id="64" toolbar="0" visible="false" inframe="false" stylebar="false" location="1" size="480" window="50,50,500,500" />
<view id="128" visible="false" inframe="false" stylebar="false" location="1" size="480" window="50,50,500,500" />
<view id="70" toolbar="0 || 2020 || 2021 || 2022" visible="false" inframe="false" stylebar="true" location="1" size="900" window="50,50,500,500" />
<view id="43" visible="false" inframe="false" stylebar="false" location="1" size="450" window="50,50,500,500" />
</views>
<toolbar show="true" items="0 73 62 | 1 501 67 , 5 19 , 72 75 76 | 2 15 45 , 18 65 , 7 37 | 4 3 8 9 , 13 44 , 58 , 47 | 16 51 64 , 70 | 10 34 53 11 , 24 20 22 , 21 23 | 55 56 57 , 12 | 36 46 , 38 49 50 , 71 14 68 | 30 29 54 32 31 33 | 25 17 26 60 52 61 | 40 41 42 , 27 28 35 , 6" position="1" help="false" />
<input show="true" cmd="true" top="algebra" />
<dockBar show="false" east="false" />
</perspective>
</perspectives>
<labelingStyle val="0"/>
<font size="16"/>
</gui>
<euclidianView>
<viewNumber viewNo="1"/>
<size width="416" height="611"/>
<coordSystem xZero="52.14293122274188" yZero="384.60776142327353" scale="40.369591199384416" yscale="40.369591199384445"/>
<evSettings axes="true" grid="false" gridIsBold="false" pointCapturing="3" rightAngleStyle="1" checkboxSize="26" gridType="3"/>
<bgColor r="255" g="255" b="255"/>
<axesColor r="0" g="0" b="0"/>
<gridColor r="192" g="192" b="192"/>
<lineStyle axes="1" grid="0"/>
<axis id="0" show="true" label="" unitLabel="" tickStyle="1" showNumbers="true"/>
<axis id="1" show="true" label="" unitLabel="" tickStyle="1" showNumbers="true"/>
</euclidianView>
<euclidianView>
<viewNumber viewNo="2"/>
<size width="468" height="611"/>
<coordSystem xZero="81.10268331149763" yZero="513.2332502592346" scale="36.77455045296211" yscale="36.7745504529621"/>
<evSettings axes="true" grid="true" gridIsBold="false" pointCapturing="3" rightAngleStyle="1" checkboxSize="26" gridType="3"/>
<bgColor r="255" g="255" b="255"/>
<axesColor r="0" g="0" b="0"/>
<gridColor r="192" g="192" b="192"/>
<lineStyle axes="1" grid="0"/>
<axis id="0" show="true" label="" unitLabel="" tickStyle="1" showNumbers="true"/>
<axis id="1" show="true" label="" unitLabel="" tickStyle="1" showNumbers="true"/>
</euclidianView>
<algebraView>
<mode val="3"/>
</algebraView>
<kernel>
<continuous val="false"/>
<usePathAndRegionParameters val="true"/>
<decimals val="2"/>
<angleUnit val="degree"/>
<algebraStyle val="3" spreadsheet="0"/>
<coordStyle val="0"/>
<startAnimation val="true"/>
</kernel>
<tableview min="-2" max="2" step="1"/>
<scripting blocked="false" disabled="false"/>
<construction title="将军饮马" author="" date="">
<element type="point" label="A">
<show object="true" label="true"/>
<objColor r="77" g="77" b="255" alpha="0"/>
<layer val="0"/>
<labelMode val="0"/>
<animation step="1" speed="1" type="1" playing="false"/>
<coords x="1" y="3" z="1"/>
<pointSize val="5"/>
<pointStyle val="0"/>
</element>
<element type="point" label="B">
<show object="true" label="true"/>
<objColor r="77" g="77" b="255" alpha="0"/>
<layer val="0"/>
<labelMode val="0"/>
<animation step="1" speed="1" type="1" playing="false"/>
<coords x="5" y="1" z="1"/>
<pointSize val="5"/>
<pointStyle val="0"/>
</element>
<command name="Segment">
<input a0="(-1, 0)" a1="(8, 0)"/>
<output a0="PBar"/>
</command>
<element type="segment" label="PBar">
<show object="true" label="false"/>
<objColor r="0" g="0" b="0" alpha="0"/>
<layer val="0"/>
<labelMode val="0"/>
<coords x="0" y="9" z="0"/>
<lineStyle thickness="5" type="0" typeHidden="1" opacity="178"/>
<outlyingIntersections val="false"/>
<keepTypeOnTransform val="true"/>
</element>
<command name="Point">
<input a0="PBar"/>
<output a0="P"/>
</command>
<element type="point" label="P">
<show object="true" label="true"/>
<objColor r="125" g="125" b="255" alpha="0"/>
<layer val="0"/>
<labelMode val="0"/>
<animation step="1" speed="1" type="1" playing="true"/>
<coords x="6.873124999999229" y="0" z="1"/>
<pointSize val="5"/>
<pointStyle val="0"/>
</element>
<command name="Segment">
<input a0="P" a1="A"/>
<output a0="sPA"/>
</command>
<element type="segment" label="sPA">
<show object="true" label="true"/>
<objColor r="0" g="0" b="0" alpha="0"/>
<layer val="0"/>
<labelMode val="2"/>
<coords x="-3" y="-5.873124999999229" z="20.61937499999769"/>
<lineStyle thickness="5" type="0" typeHidden="1" opacity="178"/>
<outlyingIntersections val="false"/>
<keepTypeOnTransform val="true"/>
</element>
<command name="Segment">
<input a0="P" a1="B"/>
<output a0="sPB"/>
</command>
<element type="segment" label="sPB">
<show object="true" label="true"/>
<objColor r="0" g="0" b="0" alpha="0"/>
<layer val="0"/>
<labelMode val="2"/>
<coords x="-1" y="-1.873124999999229" z="6.873124999999229"/>
<lineStyle thickness="5" type="0" typeHidden="1" opacity="178"/>
<outlyingIntersections val="false"/>
<keepTypeOnTransform val="true"/>
</element>
<expression label="sum1" exp="sPA + sPB" />
<element type="numeric" label="sum1">
<value val="8.718313342797877"/>
<objColor r="0" g="0" b="0" alpha="0.10000000149011612"/>
</element>
<expression label="F1" exp="(x(P), sum1)" type="point" />
<element type="point" label="F1">
<show object="true" label="true" ev="7"/>
<condition showObject="a"/>
<objColor r="68" g="68" b="68" alpha="0"/>
<layer val="0"/>
<labelMode val="2"/>
<coords x="6.873124999999229" y="8.718313342797877" z="1"/>
<pointSize val="4"/>
<pointStyle val="0"/>
</element>
<command name="Locus">
<input a0="F1" a1="P"/>
<output a0="loc1"/>
</command>
<element type="locus" label="loc1">
<show object="true" label="false" ev="11"/>
<condition showObject="a"/>
<objColor r="255" g="0" b="0" alpha="0"/>
<layer val="0"/>
<labelMode val="0"/>
<auxiliary val="false"/>
<lineStyle thickness="5" type="0" typeHidden="1" opacity="178"/>
</element>
<command name="Mirror">
<input a0="B" a1="PBar"/>
<output a0="B'"/>
</command>
<element type="point" label="B'">
<show object="true" label="true" ev="8"/>
<objColor r="77" g="77" b="255" alpha="0"/>
<layer val="0"/>
<labelMode val="0"/>
<coords x="5" y="-1" z="1"/>
<pointSize val="5"/>
<pointStyle val="0"/>
</element>
<command name="Intersect">
<input a0="PBar" a1="Line[A, B']"/>
<output a0="P1"/>
</command>
<element type="point" label="P1">
<show object="true" label="true" ev="4"/>
<condition showObject="a"/>
<objColor r="255" g="0" b="0" alpha="0"/>
<layer val="0"/>
<labelOffset x="-14" y="36"/>
<labelMode val="0"/>
<coords x="144" y="0" z="36"/>
<pointSize val="4"/>
<pointStyle val="0"/>
</element>
<command name="Segment">
<input a0="P1" a1="A"/>
<output a0="sP1A"/>
</command>
<element type="segment" label="sP1A">
<show object="true" label="false"/>
<condition showObject="a"/>
<objColor r="0" g="0" b="255" alpha="0"/>
<layer val="0"/>
<labelMode val="0"/>
<coords x="-3" y="-3" z="12"/>
<lineStyle thickness="5" type="10" typeHidden="1" opacity="178"/>
<outlyingIntersections val="false"/>
<keepTypeOnTransform val="true"/>
</element>
<command name="Segment">
<input a0="P1" a1="B"/>
<output a0="sP1B"/>
</command>
<element type="segment" label="sP1B">
<show object="true" label="false"/>
<condition showObject="a"/>
<objColor r="0" g="0" b="255" alpha="0"/>
<layer val="0"/>
<labelMode val="0"/>
<coords x="-1" y="1" z="4"/>
<lineStyle thickness="5" type="10" typeHidden="1" opacity="178"/>
<outlyingIntersections val="false"/>
<keepTypeOnTransform val="true"/>
</element>
<command name="Segment">
<input a0="P1" a1="B'"/>
<output a0="sP1B'"/>
</command>
<element type="segment" label="sP1B'">
<show object="true" label="false"/>
<condition showObject="a"/>
<objColor r="0" g="0" b="255" alpha="0"/>
<layer val="0"/>
<labelOffset x="-4" y="34"/>
<labelMode val="0"/>
<coords x="1" y="1" z="-4"/>
<lineStyle thickness="5" type="10" typeHidden="1" opacity="178"/>
<outlyingIntersections val="false"/>
<keepTypeOnTransform val="true"/>
</element>
<expression label="F1m" exp="(x(P1), sP1A + sP1B)" type="point" />
<element type="point" label="F1m">
<show object="true" label="true" ev="7"/>
<condition showObject="a"/>
<objColor r="68" g="68" b="68" alpha="0"/>
<layer val="0"/>
<labelOffset x="-9" y="32"/>
<labelMode val="2"/>
<coords x="4" y="5.656854249492381" z="1"/>
<pointSize val="4"/>
<pointStyle val="0"/>
</element>
<element type="boolean" label="a">
<value val="true"/>
<show object="true" label="true"/>
<objColor r="0" g="0" b="0" alpha="0"/>
<layer val="0"/>
<labelOffset x="201" y="69"/>
<labelMode val="4"/>
<checkbox fixed="true"/>
<caption val="PA+PB的最小值"/>
</element>
</construction>
</geogebra>