<p>The tangent space is spanned by the tangent to the point and the bitangent (which is orthogonal to both tangent and normal).</p>

<p>So you need to calculate the tangent which is achieved by calculating the cross-product of the ray-direction and the normal. $T = N \times DIR$
The resulting vector will be orthogonal to the normal and thereby be the tangent.</p>

<p>Now calculate the cross-product of the tangent and the normal $BT = T \times N$ to create a vector orthogonal to both. This vector is the bitangent.</p>

<p>Tangent $T$ and bitangent $BT$ span a plane which is the tangent-space of your intersection-point.</p>

CC BY-SA 3.0
2016-01-22T20:49:11.507Z
Hi @Dragonseel thank you for your answer. I read somewhere on the web that you could also need the texture coordinate to calculate the tangent space. Are there other procedure that could be used to calculate the tangent space?
Fabrizio Duroni
CC BY-SA 3.0
2016-01-22T20:51:29.750Z
Nice answer. I edited it to apply MathJax. A minor note: You can't use $DIR$ for the pixel that looks directly at the sphere, because of linear dependency to $N$. But actually you could use any vector instead of $DIR$ that is linearly independent. Or am I missing something?
Nero
CC BY-SA 3.0
2016-01-22T21:18:56.590Z
I don't know about the texture coordinate, but given that you already have the intersection-point and the normal calculating two cross-products seems to be very cost effective way. Yes, any vector that is linearly independent can be used. I wrote $DIR$ because it is an easily usable vector. You could just invent a way to generate a non-linear dependent vector (switch two components comes to mind, but I'm not that sure).
Dragonseel
CC BY-SA 3.0
2016-01-22T23:15:56.423Z
If the tangent space is to be used for texture mapping (e.g. filtering, normal mapping etc) then it's convenient for the tangent space axes to be aligned with the texture UV axes. But if any arbitrary tangent space is fine, then [an arbitary vector orthogonal to the normal](http://lolengine.net/blog/2013/09/21/picking-orthogonal-vector-combing-coconuts) can be used.
Nathan Reed
CC BY-SA 3.0
2016-01-22T20:15:57.553Z
2016-01-22T20:41:40.293Z
2016-01-22T20:41:40.293Z
Dragonseel
<p>In a ray tracer, given a point on a sphere (point_of_intersection with a ray) and its normal for that point (point_of_intersection - center_of_sphere) <strong>how do I calculate the tangent space for that point? Do I need other data to calculate the tangent space?</strong></p>

<raytracing><mathematics>
Ray tracing - tangent space for a point on a sphere
Fabrizio Duroni
# Ray tracing - tangent space for a point on a sphere

(Asked by: username_0 on 2016-01-22)

In a ray tracer, given a point on a sphere (point\_of\_intersection with a ray) and its normal for that point (point\_of\_intersection - center\_of\_sphere) **how do I calculate the tangent space for that point? Do I need other data to calculate the tangent space?**

**Tags:** raytracing, mathematics


---

## 1 answers

### Answer by username_1 on 2016-01-22. Score: 4 | Accepted answer

The tangent space is spanned by the tangent to the point and the bitangent (which is orthogonal to both tangent and normal).

So you need to calculate the tangent which is achieved by calculating the cross-product of the ray-direction and the normal. $T = N \times DIR$
The resulting vector will be orthogonal to the normal and thereby be the tangent.

Now calculate the cross-product of the tangent and the normal $BT = T \times N$ to create a vector orthogonal to both. This vector is the bitangent.

Tangent $T$ and bitangent $BT$ span a plane which is the tangent-space of your intersection-point.

> **Comments:**
> **username_0**: Hi @username_1 thank you for your answer. I read somewhere on the web that you could also need the texture coordinate to calculate the tangent space. Are there other procedure that could be used to calculate the tangent space?  
> **username_2**: Nice answer. I edited it to apply MathJax. A minor note: You can't use $DIR$ for the pixel that looks directly at the sphere, because of linear dependency to $N$. But actually you could use any vector instead of $DIR$ that is linearly independent. Or am I missing something?  
> **username_1**: I don't know about the texture coordinate, but given that you already have the intersection-point and the normal calculating two cross-products seems to be very cost effective way. Yes, any vector that is linearly independent can be used. I wrote $DIR$ because it is an easily usable vector. You could just invent a way to generate a non-linear dependent vector (switch two components comes to mind, but I'm not that sure).  
> **username_3**: If the tangent space is to be used for texture mapping (e.g. filtering, normal mapping etc) then it's convenient for the tangent space axes to be aligned with the texture UV axes. But if any arbitrary tangent space is fine, then [an arbitary vector orthogonal to the normal](http://lolengine.net/blog/2013/09/21/picking-orthogonal-vector-combing-coconuts) can be used.  

---

