Skip to content

Commit 502c846

Browse files
committed
easy hint for intro-3
1 parent d66da1b commit 502c846

File tree

1 file changed

+6
-17
lines changed

1 file changed

+6
-17
lines changed

exercises/intro-3/README.md

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,15 @@ In this lesson, you will write a GLSL function which computes the unit angle bis
66

77
As an example, if `a = vec2(1,0)` and `b = vec2(0,1)`, then you should return the result `vec2(sqrt(2)/2, sqrt(2)/2)`.
88

9-
**Hint** It is useful to remember the angle bisector theorem. In ascii art, suppose we have two vectors, A and B. Then the angle bisector between A and B is the vector C:
9+
## Hint
1010

11-
```
12-
B
13-
^
14-
|\
15-
| \^ C
16-
| /\
17-
|/ \
18-
*----> A
19-
O
20-
```
21-
22-
In this situation, the angle bisector theorem tells us the following information about the ratio of the lengths of these vectors:
11+
To compute the angle bisector between two vectors, you can use the following formula:
2312

24-
```glsl
25-
length(B - C) / length(C - A) == length(B) / length(A)
2613
```
27-
28-
Using the above equation, solve for the position of C and then normalize it to unit length.
14+
vec3 bisector(vec3 a, vec3 b) {
15+
return normalize(length(b) * a + length(a) * b);
16+
}
17+
```
2918

3019
***
3120

0 commit comments

Comments
 (0)