4.2.8.1 - Vectors, translation and dot products (VB.NET)
Represent vectors as lists, arrays and functions, interpret their geometry, and calculate combinations, dot products and angles. This VB.NET route uses written code with no Run: incomplete: runnable support pending.
List, array and function representations
A vector is an ordered collection of components drawn from one field, such as the real numbers.
The list represents a four-vector over , written as an element of . Order matters: swapping the first two entries changes the vector. All four entries come from the same field; mixing a String label with numeric components does not form a real vector.
The same vector has a function interpretation: , where is the domain and is the codomain. Its mappings are , , and . The symbol means “maps to”; indices choose components rather than representing separate geometric axes in code.
VB.NET can hold the same ordered components in a list or one-dimensional array, or use a dictionary to make the function's index-to-value mapping explicit. These declarations belong inside a procedure with System.Collections.Generic imported.
Dim components As New List(Of Double) From {2.0, 3.14159, -1.0, 2.718281828}
Dim values() As Double = {2.0, 3.14159, -1.0, 2.718281828}
Dim mapping As New Dictionary(Of Integer, Double) From {
{0, 2.0}, {1, 3.14159}, {2, -1.0}, {3, 2.718281828}}
Dim example(3) As Single
example(3) allocates four entries, initially zero; it does not initialise the example's values. Single and Double store finite approximations to real numbers. The mathematical vector's field remains , not the finite set of representable floating-point values. A complete dictionary representation needs exactly the intended index mappings; dictionary enumeration order is not the component order.
Geometric vectors
A two-component vector can describe a point or the displacement represented by an arrow.
For , draw the arrow from origin to : two units right and three units up. The same displacement can start elsewhere. From , it ends at . The starting location changes, but the arrow's components, direction and magnitude remain the same.
A point vector records position relative to an origin; subtracting point vectors gives a displacement between points. The length of is . For , the length is . A negative component points left or down; the magnitude cannot be negative. A zero vector has no direction and cannot define an angle through the usual division-by-length formula.
Addition, scaling and convex combinations
Vector arithmetic works component by component and has a geometric meaning.
With and , . Adding displacement translates a point at to the new position , or can be visualised by placing arrows head to tail. Multiplying by 2 scales to . A positive scalar preserves direction, a negative scalar reverses it, and zero gives the zero vector. Addition requires matching dimensions.
Continue this lesson.
You’re previewing NovaLearn without an account. Create a free account to read the rest.
Create free account