title: Return values for arccosine?
body: <p>I implemented a day/night shader built on the basis that only pixels on the side of an object that is facing the directional light source are illuminated. I calculate this based on the unit vectors between the directional light's position and the position of the pixel in 3D space:</p>
  
  <pre><code>float3 direction = normalize(Light.Position - Object.Position);
  float theta = abs(acos(dot(normalize(Object.Position), direction))) * 180 / 3.14f;
  if (theta &lt; 180)
      color = float3(1.0f);
  else
      color = float3(0.2f);
  
  return float4(color, 1.0f);
  </code></pre>
  
  <p>This works well, but since I am brushing up on my math lately, it got me thinking that I should make sure I understand what <code>acos</code> is returning.</p>
  
  <hr>
  
  <p>Mathematically, I know that the arccosine should give me an angle in radians from a value between <code>-1</code> and <code>1</code>, while cosine should give me a value between <code>-1</code> and <code>1</code> from an angle in radians.</p>
  
  <p>The <a href="https://docs.microsoft.com/en-us/windows/desktop/direct3dhlsl/dx-graphics-hlsl-acos" rel="nofollow noreferrer">documentation</a> states that the input value should be between <code>-1</code> and <code>1</code> for <code>acos</code> which follows that idea, but it doesn't tell me if the return value is <code>0 - π</code>, <code>-π - π</code>, <code>0 - 2π</code>, or a similar range.</p>
  
  <blockquote>
    <h2><strong>Return Value</strong></h2>
    
    <p>The arccosine of the x parameter.</p>
    
    <h2>Type Description</h2>
    
    <p>Name [Template Type] 'Component Type' Size<br>
    x [scalar, vector, or matrix] 'float' any<br>
    ret [same as input x] 'float' same dimension(s) as input x</p>
  </blockquote>
  
  <p><code>HLSL</code> doesn't really give me a way to test this very easily, so I'm wondering if anyone has any documentation on this.</p>
  
  <hr>
  
  <p>What is the return range for the HLSL function <code>acos</code>?</p>