Rechercher une page de manuel
sin.3Cg
Langue: en
Version: 344846 (ubuntu - 24/10/10)
Section: 3 (Bibliothèques de fonctions)
NAME
sin - returns sine of scalars and vectors.SYNOPSIS
float sin(float a); float1 sin(float1 a); float2 sin(float2 a); float3 sin(float3 a); float4 sin(float4 a);
half sin(half a); half1 sin(half1 a); half2 sin(half2 a); half3 sin(half3 a); half4 sin(half4 a);
fixed sin(fixed a); fixed1 sin(fixed1 a); fixed2 sin(fixed2 a); fixed3 sin(fixed3 a); fixed4 sin(fixed4 a);
PARAMETERS
- a
- Vector or scalar of which to determine the sine.
DESCRIPTION
Returns the sine of a in radians. The return value is in the range [-1,+1].For vectors, the returned vector contains the sine of each element of the input vector.
REFERENCE IMPLEMENTATION
sin is best implemented as a native sine instruction, however sin for a float scalar could be implemented by an approximation like this.float sin(float a) { /* C simulation gives a max absolute error of less than 1.8e-7 */ float4 c0 = float4( 0.0, 0.5, 1.0, 0.0 ); float4 c1 = float4( 0.25, -9.0, 0.75, 0.159154943091 ); float4 c2 = float4( 24.9808039603, -24.9808039603, -60.1458091736, 60.1458091736 ); float4 c3 = float4( 85.4537887573, -85.4537887573, -64.9393539429, 64.9393539429 ); float4 c4 = float4( 19.7392082214, -19.7392082214, -1.0, 1.0 );
/* r0.x = sin(a) */ float3 r0, r1, r2;
r1.x = c1.w * a - c1.x; // only difference from cos! r1.y = frac( r1.x ); // and extract fraction r2.x = (float) ( r1.y < c1.x ); // range check: 0.0 to 0.25 r2.yz = (float2) ( r1.yy >= c1.yz ); // range check: 0.75 to 1.0 r2.y = dot( r2, c4.zwz ); // range check: 0.25 to 0.75 r0 = c0.xyz - r1.yyy; // range centering r0 = r0 * r0; r1 = c2.xyx * r0 + c2.zwz; // start power series r1 = r1 * r0 + c3.xyx; r1 = r1 * r0 + c3.zwz; r1 = r1 * r0 + c4.xyx; r1 = r1 * r0 + c4.zwz; r0.x = dot( r1, -r2 ); // range extract
return r0.x; }
PROFILE SUPPORT
sin is fully supported in all profiles unless otherwise specified.sin is supported via an approximation (shown above) in the vs_1, vp20, and arbvp1 profiles.
sin is unsupported in the fp20, ps_1_1, ps_1_2, and ps_1_3 profiles.
SEE ALSO
asin, cos, dot, frac, sincos, tanContenus ©2006-2024 Benjamin Poulain
Design ©2006-2024 Maxime Vantorre