Skip to content

Commit 868063f

Browse files
authored
Merge pull request #5 from TakanoTaiga/code_refactoring
Code refactoring
2 parents d914348 + f3c6259 commit 868063f

File tree

6 files changed

+290
-130
lines changed

6 files changed

+290
-130
lines changed

.github/workflows/c-cpp.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ jobs:
1414
steps:
1515
- uses: actions/checkout@v3
1616
- name: build
17-
run: g++ -std=c++11 -O2 ./*.cpp
17+
run: g++ -std=c++17 -O2 ./*.cpp

.vscode/settings.json

Lines changed: 77 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,81 @@
11
{
22
"files.associations": {
3-
"chrono": "cpp"
3+
"chrono": "cpp",
4+
"cctype": "cpp",
5+
"clocale": "cpp",
6+
"cmath": "cpp",
7+
"cstdarg": "cpp",
8+
"cstddef": "cpp",
9+
"cstdio": "cpp",
10+
"cstdlib": "cpp",
11+
"cstring": "cpp",
12+
"ctime": "cpp",
13+
"cwchar": "cpp",
14+
"cwctype": "cpp",
15+
"array": "cpp",
16+
"atomic": "cpp",
17+
"strstream": "cpp",
18+
"bit": "cpp",
19+
"*.tcc": "cpp",
20+
"bitset": "cpp",
21+
"cfenv": "cpp",
22+
"cinttypes": "cpp",
23+
"compare": "cpp",
24+
"complex": "cpp",
25+
"concepts": "cpp",
26+
"condition_variable": "cpp",
27+
"cstdint": "cpp",
28+
"deque": "cpp",
29+
"forward_list": "cpp",
30+
"list": "cpp",
31+
"map": "cpp",
32+
"set": "cpp",
33+
"string": "cpp",
34+
"unordered_map": "cpp",
35+
"unordered_set": "cpp",
36+
"vector": "cpp",
37+
"exception": "cpp",
38+
"algorithm": "cpp",
39+
"functional": "cpp",
40+
"iterator": "cpp",
41+
"memory": "cpp",
42+
"memory_resource": "cpp",
43+
"numeric": "cpp",
44+
"optional": "cpp",
45+
"random": "cpp",
46+
"ratio": "cpp",
47+
"string_view": "cpp",
48+
"system_error": "cpp",
49+
"tuple": "cpp",
50+
"type_traits": "cpp",
51+
"utility": "cpp",
52+
"hash_map": "cpp",
53+
"hash_set": "cpp",
54+
"slist": "cpp",
55+
"fstream": "cpp",
56+
"initializer_list": "cpp",
57+
"iomanip": "cpp",
58+
"iosfwd": "cpp",
59+
"iostream": "cpp",
60+
"istream": "cpp",
61+
"limits": "cpp",
62+
"mutex": "cpp",
63+
"new": "cpp",
64+
"numbers": "cpp",
65+
"ostream": "cpp",
66+
"semaphore": "cpp",
67+
"shared_mutex": "cpp",
68+
"sstream": "cpp",
69+
"stdexcept": "cpp",
70+
"stop_token": "cpp",
71+
"streambuf": "cpp",
72+
"thread": "cpp",
73+
"typeindex": "cpp",
74+
"typeinfo": "cpp",
75+
"variant": "cpp",
76+
"csignal": "cpp",
77+
"any": "cpp",
78+
"codecvt": "cpp",
79+
"future": "cpp"
480
}
581
}

matrixutil.hpp

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
// Copyright 2024 Taiga Takano
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
#ifndef NDTCPP_MATRIX_UTIL_HPP_
16+
#define NDTCPP_MATRIX_UTIL_HPP_
17+
18+
#include "type.hpp"
19+
20+
namespace ndtcpp
21+
{
22+
auto operator*(const mat3x3& mat1, const mat3x3& mat2)
23+
{
24+
mat3x3 result;
25+
result.a = mat1.a * mat2.a + mat1.b * mat2.d + mat1.c * mat2.g;
26+
result.b = mat1.a * mat2.b + mat1.b * mat2.e + mat1.c * mat2.h;
27+
result.c = mat1.a * mat2.c + mat1.b * mat2.f + mat1.c * mat2.i;
28+
29+
result.d = mat1.d * mat2.a + mat1.e * mat2.d + mat1.f * mat2.g;
30+
result.e = mat1.d * mat2.b + mat1.e * mat2.e + mat1.f * mat2.h;
31+
result.f = mat1.d * mat2.c + mat1.e * mat2.f + mat1.f * mat2.i;
32+
33+
result.g = mat1.g * mat2.a + mat1.h * mat2.d + mat1.i * mat2.g;
34+
result.h = mat1.g * mat2.b + mat1.h * mat2.e + mat1.i * mat2.h;
35+
result.i = mat1.g * mat2.c + mat1.h * mat2.f + mat1.i * mat2.i;
36+
return result;
37+
}
38+
39+
auto operator*(const mat3x3& mat, const point3& vec)
40+
{
41+
point3 result;
42+
result.x = mat.a * vec.x + mat.b * vec.y + mat.c * vec.z;
43+
result.y = mat.d * vec.x + mat.e * vec.y + mat.f * vec.z;
44+
result.z = mat.g * vec.x + mat.h * vec.y + mat.i * vec.z;
45+
return result;
46+
}
47+
48+
auto operator+=(mat3x3& mat1, const mat3x3& mat2)
49+
{
50+
mat1.a += mat2.a;
51+
mat1.b += mat2.b;
52+
mat1.c += mat2.c;
53+
54+
mat1.d += mat2.d;
55+
mat1.e += mat2.e;
56+
mat1.f += mat2.f;
57+
58+
mat1.g += mat2.g;
59+
mat1.h += mat2.h;
60+
mat1.i += mat2.i;
61+
}
62+
63+
auto operator+=(ndtcpp::point3& point1, const ndtcpp::point3& point2){
64+
point1.x += point2.x;
65+
point1.y += point2.y;
66+
point1.z += point2.z;
67+
}
68+
} // namespace ndtcpp
69+
70+
#endif // NDTCPP_MATRIX_UTIL_HPP_

0 commit comments

Comments
 (0)