RenderScript Vector Math Functions
Stay organized with collections
Save and categorize content based on your preferences.
Overview
These functions interpret the input arguments as representation of vectors in n-dimensional space.
The precision of the mathematical operations on 32 bit floats is affected by the pragmas rs_fp_relaxed and rs_fp_full. See Mathematical Constants and Functions for details.
Different precision/speed tradeoffs can be achieved by using variants of the common math functions. Functions with a name starting with
- native_: May have custom hardware implementations with weaker precision. Additionally, subnormal values may be flushed to zero, rounding towards zero may be used, and NaN and infinity input may not be handled correctly.
- fast_: May perform internal computations using 16 bit floats. Additionally, subnormal values may be flushed to zero, and rounding towards zero may be used.
Summary
| Functions | |
|---|---|
| cross | Cross product of two vectors |
| distance | Distance between two points |
| dot | Dot product of two vectors |
| fast_distance | Approximate distance between two points |
| fast_length | Approximate length of a vector |
| fast_normalize | Approximate normalized vector |
| length | Length of a vector |
| native_distance | Approximate distance between two points |
| native_length | Approximate length of a vector |
| native_normalize | Approximately normalize a vector |
| normalize | Normalize a vector |
Functions
cross : Cross product of two vectors
Computes the cross product of two vectors.
distance : Distance between two points
Compute the distance between two points.
See also fast_distance(), native_distance().
dot : Dot product of two vectors
Computes the dot product of two vectors.
fast_distance : Approximate distance between two points
Computes the approximate distance between two points.
The precision is what would be expected from doing the computation using 16 bit floating point values.
See also distance(), native_distance().
fast_length : Approximate length of a vector
Computes the approximate length of a vector.
The precision is what would be expected from doing the computation using 16 bit floating point values.
See also length(), native_length().
fast_normalize : Approximate normalized vector
Approximately normalizes a vector.
For vectors of size 1, returns -1.f for negative values, 0.f for null values, and 1.f for positive values.
The precision is what would be expected from doing the computation using 16 bit floating point values.
See also normalize(), native_normalize().
length : Length of a vector
Computes the length of a vector.
See also fast_length(), native_length().
native_distance : Approximate distance between two points
Computes the approximate distance between two points.
See also distance(), fast_distance().
native_length : Approximate length of a vector
Compute the approximate length of a vector.
See also length(), fast_length().
native_normalize : Approximately normalize a vector
Approximately normalizes a vector.
See also normalize(), fast_normalize().
normalize : Normalize a vector
Normalize a vector.
For vectors of size 1, returns -1.f for negative values, 0.f for null values, and 1.f for positive values.
See also fast_normalize(), native_normalize().