<slopeField/>
<slopeField/> is a Graphical component
that draws the slope field of a differential equation <graph>.
The slope function is given inside the component, either as a bare expression —
<slopeField>y - x</slopeField> — or as a <function> child. A bare expression is read
as a function of variables attribute to name them differently. A
<function> child is used exactly as written, since it names its own variables.
A function whose number of outputs does not suit the component — a two-output expression such as
(y, -x) given to <slopeField/> — draws nothing and reports a warning saying which component
does want it.
The field re-tiles automatically as the user pans or zooms, and its marks keep a constant on-screen length — so slopes appear at their true visual angle even when the axes are not equally scaled.
Each mark is centered on its lattice point, sampling the tangent line of the solution curve through
that point. (By contrast, <vectorField/> puts an arrow’s tail on its lattice
point, since a vector has a direction to point in.)
Attributes and Properties
Attributes for <slopeField>
Other (10)
number. Default value: 1. Horizontal spacing between marks.
number. Default value: 1. Vertical spacing between marks.
layerinteger. Default value: 0. Z-order layer index used to stack graphical components (higher values render on top).
lineStylekeyword. Stroke style for lines.
| Value | Description |
|---|---|
solid | Continuous, unbroken stroke. |
dashed | Stroke composed of evenly-spaced dashes. |
dotted | Stroke composed of evenly-spaced dots. |
lineWidthnumber. Stroke width for lines, in pixels.
number. Default value: 20. Length of each mark, in pixels. Marks keep this length whatever the axis scaling, so slopes are drawn at their true visual angle.
number. Default value: 2500. Upper bound on how many marks are drawn. Zooming out past this coarsens the lattice rather than drawing an unbounded number of marks.
_variableNameList. Names of the variables a bare expression is read as a function of. Defaults to "x y". Ignored when the function is given as a <function> child, which names its own variables.
number. Default value: 0. Horizontal offset of the lattice origin.
number. Default value: 0. Vertical offset of the lattice origin.
Common to all components (9)
copyreference. Create an independent copy of another component by reference. Enter a references a $name.
disabledboolean. Default value: false. Whether this component is disabled and cannot be interacted with.
extendreference. Extend another component by reference, inheriting its children and attributes. Enter a reference as $name.
fixedboolean. Default value: false. Whether this component's value is fixed and cannot be modified.
fixLocationboolean. Default value: false. Whether this component's location is fixed (preventing it from being moved while still allowing other modifications).
hideboolean. Default value: false. Whether to hide this component from the rendered output.
isResponseboolean. Default value: false. Whether this component is treated as a response for the purposes of assessment.
nametext. The name used to reference this component from elsewhere in the document.
styleNumberinteger. Default value: 1. The style number used to select this component's visual styling from the available style definitions.
Properties for <slopeField name="s">
Other (13)
$s.disabledboolean. Whether this component is disabled and cannot be interacted with.
$s.dxnumber. Horizontal spacing between marks.
$s.dynumber. Vertical spacing between marks.
$s.fixedboolean. Whether this component's value is fixed and cannot be modified.
$s.fixLocationboolean. Whether this component's location is fixed (preventing it from being moved while still allowing other modifications).
$s.layerinteger. Z-order layer index used to stack graphical components (higher values render on top).
$s.markLengthnumber. Length of each mark, in pixels. Marks keep this length whatever the axis scaling, so slopes are drawn at their true visual angle.
$s.maxMarksnumber. Upper bound on how many marks are drawn. Zooming out past this coarsens the lattice rather than drawing an unbounded number of marks.
$s.styleDescriptiontext. A textual description of the slope field's style.
$s.styleDescriptionWithNountext. Style description including the noun "slope field".
$s.xoffsetnumber. Horizontal offset of the lattice origin.
$s.yoffsetnumber. Vertical offset of the lattice origin.
Common to all components (4)
$s.doenetMLtext. The DoenetML source code that produced this component.
$s.hideboolean. Whether to hide this component from the rendered output.
$s.isResponseboolean. Whether this component is treated as a response for the purposes of assessment.
$s.styleNumberinteger. The style number used to select this component's visual styling from the available style definitions.
Examples
Example: A slope field from an expression
Given directly as a child, the expression becomes the slope function. Here
Example: A slope field of two variables
The slope may depend on
Example: A solution curve through the field
Drawing a known solution on top of the field shows the curve following the marks everywhere. Here the slope function is defined separately and referenced inside the field, which is the alternative to writing the expression out.
Attribute Examples
Attribute Example: variables
variables names the inputs of a bare expression, in order: the horizontal axis first, then the
vertical. It defaults to x y, so an equation written in those letters needs nothing. It has no
effect on a <function> child, which names its own variables — writing both warns, since
one of them cannot be doing anything.
The names may themselves be references, exactly as on a <function>, so a student can choose
them:
The slope is r in the
first, q in the second — turns
Attribute Example: dx, dy
dx and dy set the horizontal and vertical spacing of the lattice, one unit each by default. A
finer lattice usually wants a shorter markLength so the marks do not overlap, and a thinner
lineWidth so they stay distinct where they nearly meet: a field is drawn in the component’s
selected style, and the default style’s line is 4 pixels wide — heavy once there are hundreds of
marks on screen. styleNumber="2" thins the marks as well, and recolors them.
Attribute Example: markLength
markLength is measured in pixels rather than graph units, and defaults to 20. Working in pixels is
what keeps every mark the same length, and at the correct visual angle, no matter how the axes are
scaled.
Attribute Example: xoffset, yoffset
xoffset and yoffset shift the lattice so a mark falls at (xoffset, yoffset). Both default to
0, which puts a mark at the origin.
Attribute Example: maxMarks
maxMarks bounds how many marks are drawn, and defaults to 2500. Rather than refusing to draw when
the lattice would exceed it — for instance after zooming far out — the field keeps every
Property Examples
Property Example: dx, dy, markLength
Each attribute of <slopeField/> is also available as a property of a named slope field.