Unit

Scientific.Core

Declared in Scientific.Core.pas

Defines geometric primitives and scalar-function abstractions. Vectors use Cartesian coordinates:

$$ \mathbf{v} = \begin{bmatrix}v_x \\ v_y\end{bmatrix} \in \mathbb{R}^2. $$

Interface dependencies

0

None.

Types

3
interface

Scientific.Core.IRealFunction

Visibility publicSource Scientific.Core.pas:16:16


IRealFunction = interface
end

Represents a real-valued function $f\colon\mathbb{R}\to\mathbb{R}$.

class

Scientific.Core.TRealFunction

Visibility publicSource Scientific.Core.pas:26:16

Relationships:

TRealFunction = class(TInterfacedObject, IRealFunction)
end

Supplies reference counting for concrete real-valued functions.

record

Scientific.Core.TVector2

Visibility publicSource Scientific.Core.pas:36:11


TVector2 = record
end

Stores a vector $\mathbf{v}=(v_x,v_y)$ in the Euclidean plane.

Routines

7
routine

Scientific.Core.AngleBetween

Visibility publicSource Scientific.Core.pas:123:22


function AngleBetween(const A: TVector2; const B: TVector2): Double

Measures the unsigned angle between two non-zero vectors.

$$ \theta=\arccos\!\left( \frac{\mathbf{a}\cdot\mathbf{b}} {\lVert\mathbf{a}\rVert_2\lVert\mathbf{b}\rVert_2} \right). $$

Parameters

NameDescription
AFirst vector $\mathbf{a}$.
BSecond vector $\mathbf{b}$.

Returns

The angle $\theta\in[0,\pi]$, or zero for a zero input.

routine

Scientific.Core.Distance

Visibility publicSource Scientific.Core.pas:80:18


function Distance(const A: TVector2; const B: TVector2): Double

Computes the distance between two points.

$$ d(\mathbf{a},\mathbf{b})=\lVert\mathbf{a}-\mathbf{b}\rVert_2. $$

Parameters

NameDescription
AFirst point $\mathbf{a}$.
BSecond point $\mathbf{b}$.

Returns

Their Euclidean distance.

routine

Scientific.Core.Dot

Visibility publicSource Scientific.Core.pas:59:13


function Dot(const A: TVector2; const B: TVector2): Double

Computes the Euclidean inner product.

$$ \mathbf{a}\cdot\mathbf{b}=a_xb_x+a_yb_y. $$

Parameters

NameDescription
ALeft vector $\mathbf{a}$.
BRight vector $\mathbf{b}$.

Returns

The scalar inner product.

routine

Scientific.Core.Magnitude

Visibility publicSource Scientific.Core.pas:69:19


function Magnitude(const Value: TVector2): Double

Computes the Euclidean magnitude of a vector.

$$ \lVert\mathbf{v}\rVert_2=\sqrt{v_x^2+v_y^2}. $$

Parameters

NameDescription
ValueVector $\mathbf{v}$.

Returns

Its non-negative magnitude.

routine

Scientific.Core.Normalize

Visibility publicSource Scientific.Core.pas:93:19


function Normalize(const Value: TVector2): TVector2

Produces a unit vector with the same direction.

$$ \widehat{\mathbf{v}}= \frac{\mathbf{v}}{\lVert\mathbf{v}\rVert_2}. $$

The zero vector maps to itself rather than dividing by zero.

Parameters

NameDescription
ValueVector $\mathbf{v}$ to normalize.

Returns

$\widehat{\mathbf{v}}$ or $(0,0)$ for a zero input.

routine

Scientific.Core.Rotate

Visibility publicSource Scientific.Core.pas:109:16


function Rotate(const Value: TVector2; const Angle: Double): TVector2

Rotates a vector counter-clockwise by $\theta$ radians.

$$ R(\theta)= \begin{bmatrix} \cos\theta & -\sin\theta \\ \sin\theta & \cos\theta \end{bmatrix}, \qquad \mathbf{v}'=R(\theta)\mathbf{v}. $$

Parameters

NameDescription
ValueVector $\mathbf{v}$ to rotate.
AngleRotation angle $\theta$ in radians.

Returns

The rotated vector $\mathbf{v}'$.

routine

Scientific.Core.Vector2

Visibility publicSource Scientific.Core.pas:48:17


function Vector2(const X: Double; const Y: Double): TVector2

Constructs the vector $\mathbf{v}=(x,y)$.

Parameters

NameDescription
XHorizontal component $v_x$.
YVertical component $v_y$.

Returns

A vector containing both components.

Members

4
method

Scientific.Core.IRealFunction.Evaluate

Visibility publicSource Scientific.Core.pas:22:22


function Evaluate(const X: Double): Double

Evaluates $f(x)$ at one real argument.

Parameters

NameDescription
XArgument supplied to the function.

Returns

The scalar value $f(X)$.

method

Scientific.Core.TRealFunction.Evaluate

Visibility publicSource Scientific.Core.pas:32:22


function Evaluate(const X: Double): Double; virtual; abstract

Evaluates the concrete function at $x$.

Parameters

NameDescription
XArgument supplied to the function.

Returns

The scalar value $f(X)$.