1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
use core::ops::Neg;
use num_traits::{One, Zero};
#[inline]
pub fn set<T>(out: &mut [T; 2], x: T, y: T) -> &mut [T; 2] {
out[0] = x;
out[1] = y;
out
}
#[inline(always)]
pub fn set_zero<T>(out: &mut [T; 2]) -> &mut [T; 2]
where
T: Zero,
{
set(out, T::zero(), T::zero())
}
#[inline(always)]
pub fn set_one<T>(out: &mut [T; 2]) -> &mut [T; 2]
where
T: One,
{
set(out, T::one(), T::one())
}
#[inline(always)]
pub fn set_up<T>(out: &mut [T; 2]) -> &mut [T; 2]
where
T: One + Zero,
{
set(out, T::zero(), T::one())
}
#[inline(always)]
pub fn set_down<T>(out: &mut [T; 2]) -> &mut [T; 2]
where
T: Neg<Output = T> + One + Zero,
{
set(out, T::zero(), -T::one())
}
#[inline(always)]
pub fn set_left<T>(out: &mut [T; 2]) -> &mut [T; 2]
where
T: Neg<Output = T> + One + Zero,
{
set(out, -T::one(), T::zero())
}
#[inline(always)]
pub fn set_right<T>(out: &mut [T; 2]) -> &mut [T; 2]
where
T: One + Zero,
{
set(out, T::one(), T::zero())
}
#[inline]
pub fn set_vec3<'out, T>(out: &'out mut [T; 2], v: &[T; 3]) -> &'out mut [T; 2]
where
T: Clone,
{
set(out, v[0].clone(), v[1].clone())
}
#[inline]
pub fn set_vec4<'out, T>(out: &'out mut [T; 2], v: &[T; 4]) -> &'out mut [T; 2]
where
T: Clone,
{
set(out, v[0].clone(), v[1].clone())
}