Referencevector

<vector>

A geometric vector with tail and head

<vector> is a Graphical component that renders a vector when nested within a <graph>. Outside a graph, it can be used in vector computations.

Attributes and Properties

Attributes for <vector>

Number display (5)
avoidScientificNotation

boolean. Default value: false. Whether to render numbers in full decimal form rather than scientific notation.

displayDecimals

integer. Default value: 2. Number of decimal places to display when rendering this number.

displayDigits

integer. Default value: 3. Number of significant digits to display when rendering this number.

displaySmallAsZero

number. Default value: 1e-14. Threshold below which numbers are displayed as zero.

padZeros

boolean. Default value: false. Whether to pad displayed numbers with trailing zeros to fill the requested digits/decimals.

Labels (1)
labelIsName

boolean. Default value: false. Whether to use this component's name as its rendered label.

Other (19)
addControls

keyword. Whether to render interactive control handles.

ValueDescription
displacement (default)Show a control handle for translating the whole vector.
headAndTailShow control handles for both the head and the tail.
headOnlyShow a control handle only at the head.
tailOnlyShow a control handle only at the tail.
noneShow no control handles.
applyStyleToLabel

boolean. Default value: false. Whether to apply this component's selected style to its label.

controlOrder

integer. Default value: 0. Slot order for graph controls (1-indexed; 0 means no explicit slot request).

[ coords ]. The vector's displacement (head minus tail).

boolean. Default value: false. Whether to display the vector with angle brackets (e.g. ⟨1,2⟩).

boolean. Default value: true. Whether the vector can be dragged on a graph.

[ point ]. The head (tip) point of the vector.

boolean. Whether the vector's head can be dragged.

labelPosition

keyword. Where the label sits along this line/curve.

ValueDescription
upperRightPlace the label above and to the right of the line.
upperLeftPlace the label above and to the left of the line.
lowerRightPlace the label below and to the right of the line.
lowerLeftPlace the label below and to the left of the line.
center (default)Place the label at the midpoint of the line.
topPlace the label directly above the line.
bottomPlace the label directly below the line.
leftPlace the label directly to the left of the line.
rightPlace the label directly to the right of the line.
layer

integer. Default value: 0. Z-order layer index used to stack graphical components (higher values render on top).

lineStyle

keyword. Stroke style for lines.

ValueDescription
solidContinuous, unbroken stroke.
dashedStroke composed of evenly-spaced dashes.
dottedStroke composed of evenly-spaced dots.
lineWidth

number. Stroke width for lines, in pixels.

showCoordsWhenDragging

boolean. Default value: true. Whether to show coordinate labels while dragging.

[ point ]. The tail (base) point of the vector.

boolean. Whether the vector's tail can be dragged.

math. The first component (x) of the vector's displacement.

mathList. The vector's displacement components as a list.

math. The second component (y) of the vector's displacement.

z

math. The third component (z) of the vector's displacement.

Common to all components (9)
copy

reference. Create an independent copy of another component by reference. Enter a references a $name.

disabled

boolean. Default value: false. Whether this component is disabled and cannot be interacted with.

extend

reference. Extend another component by reference, inheriting its children and attributes. Enter a reference as $name.

fixed

boolean. Default value: false. Whether this component's value is fixed and cannot be modified.

fixLocation

boolean. Default value: false. Whether this component's location is fixed (preventing it from being moved while still allowing other modifications).

hide

boolean. Default value: false. Whether to hide this component from the rendered output.

isResponse

boolean. Default value: false. Whether this component is treated as a response for the purposes of assessment.

name

text. The name used to reference this component from elsewhere in the document.

styleNumber

integer. Default value: 1. The style number used to select this component's visual styling from the available style definitions.

Properties for <vector name="v">

Number display (5)
$v.avoidScientificNotation

boolean. Whether to render numbers in full decimal form rather than scientific notation.

$v.displayDecimals

integer. Number of decimal places to display when rendering this number.

$v.displayDigits

integer. Number of significant digits to display when rendering this number.

$v.displaySmallAsZero

number. Threshold below which numbers are displayed as zero.

$v.padZeros

boolean. Whether to pad displayed numbers with trailing zeros to fill the requested digits/decimals.

Labels (2)
$v.label

label. The label rendered with this component.

$v.labelIsName

boolean. Whether to use this component's name as its rendered label.

Other (28)
$v.addControls

text. Whether to render interactive control handles.

$v.applyStyleToLabel

boolean. Whether to apply this component's selected style to its label.

$v.backgroundColor

text. Human-readable name for this component's background color, derived from the active style and theme.

$v.controlOrder

integer. Slot order for graph controls (1-indexed; 0 means no explicit slot request).

$v.disabled

boolean. Whether this component is disabled and cannot be interacted with.

$v.displacement

[ math ]. The displacement (head − tail) of the vector.

$v.displayWithAngleBrackets

boolean. Whether to display the vector with angle brackets (e.g. ⟨1,2⟩).

$v.draggable

boolean. Whether the vector can be dragged on a graph.

$v.fixed

boolean. Whether this component's value is fixed and cannot be modified.

$v.fixLocation

boolean. Whether this component's location is fixed (preventing it from being moved while still allowing other modifications).

$v.head

[ math ]. Coordinates of the vector's head.

$v.headDraggable

boolean. Whether the vector's head can be dragged independently.

$v.hidden

boolean. Whether this component is hidden from the rendered output.

$v.labelPosition

text. Where the label sits along this line/curve.

latex. The vector rendered as a LaTeX string.

$v.layer

integer. Z-order layer index used to stack graphical components (higher values render on top).

math. The magnitude (length) of the vector.

number. Number of dimensions of the vector.

$v.showCoordsWhenDragging

boolean. Whether to show coordinate labels while dragging.

$v.styleDescription

text. A textual description of the vector's style.

$v.styleDescriptionWithNoun

text. Style description including the word "vector".

$v.tail

[ math ]. Coordinates of the vector's tail.

$v.tailDraggable

boolean. Whether the vector's tail can be dragged independently.

$v.textColor

text. Human-readable name for this component's text color, derived from the active style and theme.

$v.textStyleDescription

text. Human-readable description of this component's text styling (color and any background color).

$v.x

math. The first component (x) of the vector's displacement.

$v.y

math. The second component (y) of the vector's displacement.

$v.z

math. The third component (z) of the vector's displacement.

Common to all components (4)
$v.doenetML

text. The DoenetML source code that produced this component.

$v.hide

boolean. Whether to hide this component from the rendered output.

$v.isResponse

boolean. Whether this component is treated as a response for the purposes of assessment.

$v.styleNumber

integer. The style number used to select this component's visual styling from the available style definitions.

Examples

Example: Default <vector>

A default <vector> without any additional attributes has tail at the origin and head at (1,0)(1,0).


Example: <vector> math

A <vector> within a <math> follows vector operations.

Attribute Examples

Attribute Example: x,y

The x and y attributes allow the vector to be specified by its coordinates or row elements for a vector given by v=(x,y)\bf{v} = (x, y).


Attribute Example: xs

The xs attribute allows the vector to be specified by its displacements in list format. To access or render the list information, use index notation.


Attribute Example: displacement

Use the displacement property to specify the displacement of the vector in each direction from its tail position.


Attribute Example: head, tail

Use head and tail to specify the head and tail coordinates of the vector directly.


Attribute Example: displayWithAngleBrackets

If this is the desired rendering format, use the attribute displayWithAngleBrackets.


Attribute Example: draggable

The draggable attribute determines whether the <vector> can be dragged around the <graph>. All graphical objects are draggable by default.


Attribute Example: headDraggable, tailDraggable

The head and tail of a <vector> are draggable by default. Use the headDraggable or tailDraggable attribute set to false to disable users from changing the direction and length of the <vector>. The vector as a whole can still be repositioned on the <graph>.


Attribute Example: Standard graphical attributes

The uses of the following standard graphical attributes are illustrated: hide, fixLocation, layer, styleNumber, applyStyleToLabel and labelIsName.

Property Examples

Property Example: numDimensions

The numDimensions property returns the number of dimesions of the <vector>.


Property Example: magnitude

The magnitude property renders the magnitude of the named <vector>.


Property Example: latex

The latex property renders the latex code for rendering the named <vector>.