RenderScript Vector Math Functions
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 |
cross : Cross product of two vectors
Computes the cross product of two vectors.
distance : Distance between two points
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
native_distance : Approximate distance between two points
native_length : Approximate length of a vector
native_normalize : Approximately normalize a vector
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().