1# 2# Copyright (C) 2015 The Android Open Source Project 3# 4# Licensed under the Apache License, Version 2.0 (the "License"); 5# you may not use this file except in compliance with the License. 6# You may obtain a copy of the License at 7# 8# http://www.apache.org/licenses/LICENSE-2.0 9# 10# Unless required by applicable law or agreed to in writing, software 11# distributed under the License is distributed on an "AS IS" BASIS, 12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13# See the License for the specific language governing permissions and 14# limitations under the License. 15# 16 17header: 18summary: Vector Math Functions 19description: 20 These functions interpret the input arguments as representation of vectors in 21 n-dimensional space. 22 23 The precision of the mathematical operations on 32 bit floats is affected by the pragmas 24# TODO Create an anchor for the section of http://developer.android.com/guide/topics/renderscript/compute.html that details rs_fp_* and link them here. 25 rs_fp_relaxed and rs_fp_full. See <a href='rs_math.html'>Mathematical Constants and Functions</a> for details. 26 27 Different precision/speed tradeoffs can be achieved by using variants of the common math 28 functions. Functions with a name starting with<ul> 29 <li>native_: May have custom hardware implementations with weaker precision. Additionally, 30 subnormal values may be flushed to zero, rounding towards zero may be used, and NaN and 31 infinity input may not be handled correctly.</li> 32 <li>fast_: May perform internal computations using 16 bit floats. Additionally, subnormal 33 values may be flushed to zero, and rounding towards zero may be used.</li> 34 </ul> 35end: 36 37function: cross 38version: 9 39attrib: const 40w: 3, 4 41t: f32 42ret: #2#1 43arg: #2#1 left_vector 44arg: #2#1 right_vector 45summary: Cross product of two vectors 46description: 47 Computes the cross product of two vectors. 48test: vector 49end: 50 51function: distance 52version: 9 53attrib: const 54w: 1, 2, 3, 4 55t: f32 56ret: #2 57arg: #2#1 left_vector 58arg: #2#1 right_vector 59summary: Distance between two points 60description: 61 Compute the distance between two points. 62 63 See also @fast_distance(), @native_distance(). 64test: vector 65end: 66 67function: dot 68version: 9 69attrib: const 70w: 1, 2, 3, 4 71t: f32 72ret: #2 73arg: #2#1 left_vector 74arg: #2#1 right_vector 75summary: Dot product of two vectors 76description: 77 Computes the dot product of two vectors. 78test: vector 79end: 80 81function: fast_distance 82version: 17 83attrib: const 84w: 1, 2, 3, 4 85t: f32 86ret: #2 87arg: #2#1 left_vector 88arg: #2#1 right_vector 89summary: Approximate distance between two points 90description: 91 Computes the approximate distance between two points. 92 93 The precision is what would be expected from doing the computation using 16 bit floating 94 point values. 95 96 See also @distance(), @native_distance(). 97test: vector 98end: 99 100function: fast_length 101version: 17 102attrib: const 103w: 1, 2, 3, 4 104t: f32 105ret: #2 106arg: #2#1 v 107summary: Approximate length of a vector 108description: 109 Computes the approximate length of a vector. 110 111 The precision is what would be expected from doing the computation using 16 bit floating 112 point values. 113 114 See also @length(), @native_length(). 115test: vector 116end: 117 118function: fast_normalize 119version: 17 120attrib: const 121w: 1, 2, 3, 4 122t: f32 123ret: #2#1 124arg: #2#1 v 125summary: Approximate normalized vector 126description: 127 Approximately normalizes a vector. 128 129 For vectors of size 1, returns -1.f for negative values, 0.f for null values, and 1.f for 130 positive values. 131 132 The precision is what would be expected from doing the computation using 16 bit floating 133 point values. 134 135 See also @normalize(), @native_normalize(). 136test: vector 137end: 138 139function: length 140version: 9 141attrib: const 142w: 1, 2, 3, 4 143t: f32 144ret: #2 145arg: #2#1 v 146summary: Length of a vector 147description: 148 Computes the length of a vector. 149 150 See also @fast_length(), @native_length(). 151test: vector 152end: 153 154function: native_distance 155version: 21 156attrib: const 157w: 1, 2, 3, 4 158t: f32 159ret: #2 160arg: #2#1 left_vector 161arg: #2#1 right_vector 162summary: Approximate distance between two points 163description: 164 Computes the approximate distance between two points. 165 166 See also @distance(), @fast_distance(). 167test: vector 168end: 169 170function: native_length 171version: 21 172attrib: const 173w: 1, 2, 3, 4 174t: f32 175ret: #2 176arg: #2#1 v 177summary: Approximate length of a vector 178description: 179 Compute the approximate length of a vector. 180 181 See also @length(), @fast_length(). 182test: vector 183end: 184 185function: native_normalize 186version: 21 187attrib: const 188w: 1, 2, 3, 4 189t: f32 190ret: #2#1 191arg: #2#1 v 192summary: Approximately normalize a vector 193description: 194 Approximately normalizes a vector. 195 196 See also @normalize(), @fast_normalize(). 197test: vector 198end: 199 200function: normalize 201version: 9 202attrib: const 203w: 1, 2, 3, 4 204t: f32 205ret: #2#1 206arg: #2#1 v 207summary: Normalize a vector 208description: 209 Normalize a vector. 210 211 For vectors of size 1, returns -1.f for negative values, 0.f for null values, and 1.f for 212 positive values. 213 214 See also @fast_normalize(), @native_normalize(). 215test: vector 216end: 217