Skip to content

Commit 74d9176

Browse files
committed
Initial commit
0 parents  commit 74d9176

31 files changed

+2578
-0
lines changed

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 noaccessl
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# glua-SharpVector
2+
A GLua implementation of Vector.
3+
4+
Featuring rigid optimization & precise calculations due to components being doubles.
5+
6+
## Doc
7+
All pivotal details are concisely described/explained in the code.
8+
9+
All Vector functions are present. `SharpVector()` possesses the same argument overload as `Vector()`.
10+
11+
Functions compatible with `Vector`:
12+
* `SharpVector:SetGModVector( vec )`
13+
* `SharpVector:AddGModVector( vec )`
14+
* `SharpVector:SubGModVector( vec )`
15+
* `SharpVector:MulByGModVector( vec )`
16+
* `SharpVector:DivByGModVector( vec )`
17+
18+
Multiplication by `Matrix` is moved to `SharpVector:MulByMatrix( matrix )`
19+
20+
Extensions:
21+
* `Vector?` `SharpVector:ToGModVector( [vecOut] )`
22+
* `SharpVector` `Vector:Sharpened()`
23+
* `SharpVector?` `SharpVector:Lerp( sharpvecTarget, fraction[, sharpvecOut] )`
24+
25+
### Features
26+
Functions that by design return new vector/angle/color/table as the result have the last argument as the output for the result (where reasonable). (`Cross`, `ToColor`, `ToTable`, `Angle`, `AngleEx`, `Rotate`)
27+
28+
---
29+
30+
### [Performance Test](./perftest/PerfTest.md)

perftest/PerfTest.md

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
## glua-SharpVector: Performance Test
2+
Using [gluafuncbudget](https://gist.github.com/noaccessl/2336bb390aca15bc7ba50d2c9d966daa#file-gluafuncbudget-lua)
3+
4+
CPU: i7-3770
5+
6+
OS: Windows 10
7+
8+
Benchmark Code: [sharpvec_perftest.lua](./sharpvec_perftest.lua)
9+
10+
#### LuaJIT 2.1.0-beta3 (x86-64 Branch)
11+
<details> <summary>Results</summary>
12+
13+
![-](./img/x64/image-0.png)
14+
15+
![-](./img/x64/image-1.png)
16+
17+
![-](./img/x64/image-2.png)
18+
19+
![-](./img/x64/image-3.png)
20+
21+
![-](./img/x64/image-4.png)
22+
23+
![-](./img/x64/image-5.png)
24+
25+
![-](./img/x64/image-6.png)
26+
27+
![-](./img/x64/image-7.png)
28+
29+
![-](./img/x64/image-8.png)
30+
31+
![-](./img/x64/image-9.png)
32+
33+
![-](./img/x64/image-10.png)
34+
35+
![-](./img/x64/image-11.png)
36+
37+
![-](./img/x64/image-12.png)
38+
</details>
39+
40+
#### LuaJIT 2.0.4
41+
<details> <summary>Results</summary>
42+
43+
![-](./img/image-0.png)
44+
45+
![-](./img/image-1.png)
46+
47+
![-](./img/image-2.png)
48+
49+
![-](./img/image-3.png)
50+
51+
![-](./img/image-4.png)
52+
53+
![-](./img/image-5.png)
54+
55+
![-](./img/image-6.png)
56+
57+
![-](./img/image-7.png)
58+
59+
![-](./img/image-8.png)
60+
61+
![-](./img/image-9.png)
62+
63+
![-](./img/image-10.png)
64+
65+
![-](./img/image-11.png)
66+
67+
![-](./img/image-12.png)
68+
</details>
69+
70+
---
71+
72+
Functions excluded from testing and why:
73+
* Functions using metamethods declared in the engine
74+
* As internally metamethods from `C` are called, equalizing the execution time with those metamethods
75+
76+
* `Sub`
77+
* As it's the same addition but with negative numbers
78+
79+
* `Div`
80+
* As it's the same multiplication but inverted
81+
82+
* `LengthSqr`, `Length2D`, `Length2DSqr`, `DistToSqr`, `Distance2D`, `Distance2DSqr`
83+
* `Length` & `Distance` must be enough as those ones are obviously cheaper in calculations
84+
85+
* `ToGModVector` & `Vector:Sharpened`
86+
* No twin function
87+
88+
* `ToColor`
89+
* Mostly identical to `Vector:ToColor`

perftest/img/image-0.png

19.2 KB
Loading

perftest/img/image-1.png

52.3 KB
Loading

perftest/img/image-10.png

54 KB
Loading

perftest/img/image-11.png

24.3 KB
Loading

perftest/img/image-12.png

43 KB
Loading

perftest/img/image-2.png

45.6 KB
Loading

perftest/img/image-3.png

35.3 KB
Loading

perftest/img/image-4.png

34.6 KB
Loading

perftest/img/image-5.png

15.5 KB
Loading

perftest/img/image-6.png

40.6 KB
Loading

perftest/img/image-7.png

27.3 KB
Loading

perftest/img/image-8.png

23.6 KB
Loading

perftest/img/image-9.png

24.5 KB
Loading

perftest/img/x64/image-0.png

28.1 KB
Loading

perftest/img/x64/image-1.png

86.8 KB
Loading

perftest/img/x64/image-10.png

68.6 KB
Loading

perftest/img/x64/image-11.png

7.53 KB
Loading

perftest/img/x64/image-12.png

14.7 KB
Loading

perftest/img/x64/image-2.png

80.1 KB
Loading

perftest/img/x64/image-3.png

35.4 KB
Loading

perftest/img/x64/image-4.png

64.2 KB
Loading

perftest/img/x64/image-5.png

75.8 KB
Loading

perftest/img/x64/image-6.png

38.9 KB
Loading

perftest/img/x64/image-7.png

26.2 KB
Loading

perftest/img/x64/image-8.png

21.4 KB
Loading

perftest/img/x64/image-9.png

23.4 KB
Loading

0 commit comments

Comments
 (0)