vector3_arith: Arithmetic operations on vectors

vector3_arithR Documentation

Arithmetic operations on vectors

Description

Addition or subtraction requires two 'vector3' of equal length or length 1. In the case one vector is length 1, it is broadcast across the other value.

Usage

## S3 method for class 'dddr_vector3'
vec_arith(op, x, y, ...)

## Default S3 method:
vec_arith.dddr_vector3(op, x, y, ...)

## S3 method for class 'dddr_vector3'
vec_arith.dddr_vector3(op, x, y, ...)

## S3 method for class 'numeric'
vec_arith.dddr_vector3(op, x, y, ...)

## S3 method for class 'MISSING'
vec_arith.dddr_vector3(op, x, y, ...)

## S3 method for class 'dddr_vector3'
vec_arith.numeric(op, x, y, ...)

Arguments

op

Arithmetic operation, i.e, '"+"', '"-"', '"*"', or '"/"'

x, y

Operands

...

Unused; present for extensibility

Details

For multiplication or division, numeric vectors can be length 1, which is broadcast across all entries, or can be the same length as the vector3 vector, where each element is scaled individually.

See Also

vector3_math

Examples

vector3(x = 1:4, y = 2:5, z = 3:6) + vector3(x = 4:7, y = 5:8, z = 6:9)
vector3(x = 1:4, y = 2:5, z = 3:6) - vector3(2, 0, -1)

vector3(x = 1:4, y = 2:5, z = 3:6) * 4
vector3(x = 1:4, y = 2:5, z = 3:6) / c(3, 1, 4, 1)

MrMallIronmaker/dddr documentation built on May 11, 2022, 8:39 p.m.