• R/O
  • HTTP
  • SSH
  • HTTPS

提交

标签
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Mercury Geometry and Math Library


Commit MetaInfo

修订版433910f31212e2241658adbc8b8f5da607874987 (tree)
时间2022-01-24 09:26:24
作者AlaskanEmily <emily@alas...>
CommiterAlaskanEmily

Log Message

Fix formatting in matrix.m

更改概述

差异

--- a/matrix.m
+++ b/matrix.m
@@ -6,16 +6,16 @@
66
77 :- module matrix.
88
9-%==============================================================================%
9+%=============================================================================%
1010 :- interface.
11-%==============================================================================%
11+%=============================================================================%
1212
1313 :- use_module vector.
1414
1515 :- include_module matrix.invert.
1616 :- use_module matrix.invert.
1717
18-%------------------------------------------------------------------------------%
18+%-----------------------------------------------------------------------------%
1919
2020 :- type matrix ---> matrix(
2121 a::vector.vector4,
@@ -23,40 +23,40 @@
2323 c::vector.vector4,
2424 d::vector.vector4).
2525
26-%------------------------------------------------------------------------------%
26+%-----------------------------------------------------------------------------%
2727 % frustum(Left, Right, Top, Bottom, Near, Far) = Frustum.
2828 :- func frustum(float, float, float, float, float, float) = matrix.
2929
30-%------------------------------------------------------------------------------%
30+%-----------------------------------------------------------------------------%
3131
3232 :- func translate(float, float, float) = matrix.
3333
34-%------------------------------------------------------------------------------%
34+%-----------------------------------------------------------------------------%
3535
3636 :- func translate(vector.vector3) = matrix.
3737
38-%------------------------------------------------------------------------------%
38+%-----------------------------------------------------------------------------%
3939
4040 :- func scale(float, float, float) = matrix.
4141
42-%------------------------------------------------------------------------------%
42+%-----------------------------------------------------------------------------%
4343
4444 :- func scale(vector.vector3) = matrix.
4545
46-%------------------------------------------------------------------------------%
46+%-----------------------------------------------------------------------------%
4747
4848 :- func rotate(float::in, vector.vector3::in) = (matrix::uo) is det.
4949 :- func rotate_old(float::in, vector.vector3::in) = (matrix::uo) is det.
5050
51-%------------------------------------------------------------------------------%
51+%-----------------------------------------------------------------------------%
5252
5353 :- func identity = matrix.
5454
55-%------------------------------------------------------------------------------%
55+%-----------------------------------------------------------------------------%
5656
5757 :- func transpose(matrix) = matrix.
5858
59-%------------------------------------------------------------------------------%
59+%-----------------------------------------------------------------------------%
6060
6161 :- pred transpose(matrix, matrix).
6262 :- mode transpose(in, out) is det.
@@ -67,15 +67,15 @@
6767 :- mode transpose(mdi, muo) is det.
6868 :- mode transpose(muo, mdi) is det.
6969
70-%------------------------------------------------------------------------------%
70+%-----------------------------------------------------------------------------%
7171
7272 :- func (matrix::in) * (vector.vector4::in) = (vector.vector4::uo) is det.
7373
74-%------------------------------------------------------------------------------%
74+%-----------------------------------------------------------------------------%
7575
7676 :- func transform(matrix::in, vector.vector4::in) = (vector.vector4::uo) is det.
7777
78-%------------------------------------------------------------------------------%
78+%-----------------------------------------------------------------------------%
7979
8080 :- func multiply(matrix, matrix) = matrix.
8181 :- mode multiply(in, in) = (uo) is det.
@@ -97,18 +97,18 @@
9797 :- mode multiply2(in, di, uo) is det.
9898 :- mode multiply2(di, di, uo) is det.
9999
100-%------------------------------------------------------------------------------%
100+%-----------------------------------------------------------------------------%
101101
102102 :- func column_a(matrix::in) = (vector.vector4::uo) is det.
103103 :- func column_b(matrix::in) = (vector.vector4::uo) is det.
104104 :- func column_c(matrix::in) = (vector.vector4::uo) is det.
105105 :- func column_d(matrix::in) = (vector.vector4::uo) is det.
106106
107-%==============================================================================%
107+%=============================================================================%
108108 :- implementation.
109-%==============================================================================%
109+%=============================================================================%
110110
111-:- import_module exception.
111+:- use_module exception.
112112 :- import_module float.
113113 :- import_module int.
114114 :- use_module math.
@@ -116,7 +116,7 @@
116116 :- import_module vector.vector3.
117117 :- import_module vector.vector4.
118118
119-%------------------------------------------------------------------------------%
119+%-----------------------------------------------------------------------------%
120120
121121 frustum(Left, Right, Top, Bottom, Near, Far) = matrix(
122122 vector(2.0 * Near / (Right - Left), 0.0, A, 0.0),
@@ -128,7 +128,7 @@ frustum(Left, Right, Top, Bottom, Near, Far) = matrix(
128128 C = -(Far + Near) / (Far - Near),
129129 D = -2.0 * Far * Near / (Far - Near).
130130
131-%------------------------------------------------------------------------------%
131+%-----------------------------------------------------------------------------%
132132
133133 translate(X, Y, Z) = matrix(
134134 vector(1.0, 0.0, 0.0, X),
@@ -136,11 +136,11 @@ translate(X, Y, Z) = matrix(
136136 vector(0.0, 0.0, 1.0, Z),
137137 vector(0.0, 0.0, 0.0, 1.0)).
138138
139-%------------------------------------------------------------------------------%
139+%-----------------------------------------------------------------------------%
140140
141141 translate(vector(X, Y, Z)) = translate(X, Y, Z).
142142
143-%------------------------------------------------------------------------------%
143+%-----------------------------------------------------------------------------%
144144
145145 scale(X, Y, Z) = matrix(
146146 vector(X, 0.0, 0.0, 0.0),
@@ -148,15 +148,15 @@ scale(X, Y, Z) = matrix(
148148 vector(0.0, 0.0, Z, 0.0),
149149 vector(0.0, 0.0, 0.0, 1.0)).
150150
151-%------------------------------------------------------------------------------%
151+%-----------------------------------------------------------------------------%
152152
153153 scale(vector(X, Y, Z)) = scale(X, Y, Z).
154154
155-%------------------------------------------------------------------------------%
155+%-----------------------------------------------------------------------------%
156156
157157 rotate_old(A, Vec) = M :- transpose(rotate(A, Vec), M).
158158
159-%------------------------------------------------------------------------------%
159+%-----------------------------------------------------------------------------%
160160
161161 rotate(A, Vec) = matrix(
162162 vector(X*X*(1.0-C)+C, X*Y*(1.0-C)-Z*S, X*Z*(1.0-C)+Y*S, 0.0),
@@ -167,7 +167,7 @@ rotate(A, Vec) = matrix(
167167 S = math.sin(A),
168168 C = math.cos(A).
169169
170-%------------------------------------------------------------------------------%
170+%-----------------------------------------------------------------------------%
171171
172172 identity = matrix(
173173 vector(1.0, 0.0, 0.0, 0.0),
@@ -175,20 +175,20 @@ identity = matrix(
175175 vector(0.0, 0.0, 1.0, 0.0),
176176 vector(0.0, 0.0, 0.0, 1.0)).
177177
178-%------------------------------------------------------------------------------%
178+%-----------------------------------------------------------------------------%
179179
180180 (matrix(V1, V2, V3, V4)) * (V) =
181181 vector(vector.dot(V, V1), vector.dot(V, V2), vector.dot(V, V3), vector.dot(V, V4)).
182182
183-%------------------------------------------------------------------------------%
183+%-----------------------------------------------------------------------------%
184184
185185 transform(M, V) = (M * V).
186186
187-%------------------------------------------------------------------------------%
187+%-----------------------------------------------------------------------------%
188188
189189 transpose(M1) = M2 :- transpose(M1, M2).
190190
191-%------------------------------------------------------------------------------%
191+%-----------------------------------------------------------------------------%
192192
193193 transpose(
194194 matrix(
@@ -202,7 +202,7 @@ transpose(
202202 vector(C, G, K, O),
203203 vector(D, H, L, P))).
204204
205-%------------------------------------------------------------------------------%
205+%-----------------------------------------------------------------------------%
206206
207207 multiply(matrix(A, B, C, D), matrix(AIn, BIn, CIn, DIn)) = matrix(
208208 vector(vector.dot(A, E), vector.dot(A, F), vector.dot(A, G), vector.dot(A, H)),
@@ -218,9 +218,10 @@ multiply(M1, M2, multiply(M1, M2)).
218218
219219 multiply2(M2, M1, multiply(M1, M2)).
220220
221-%------------------------------------------------------------------------------%
221+%-----------------------------------------------------------------------------%
222222
223223 column_a(M) = vector(M ^ a ^ x + 0.0, M ^ b ^ x + 0.0, M ^ c ^ x + 0.0, M ^ d ^ x + 0.0).
224224 column_b(M) = vector(M ^ a ^ y + 0.0, M ^ b ^ y + 0.0, M ^ c ^ y + 0.0, M ^ d ^ y + 0.0).
225225 column_c(M) = vector(M ^ a ^ z + 0.0, M ^ b ^ z + 0.0, M ^ c ^ z + 0.0, M ^ d ^ z + 0.0).
226226 column_d(M) = vector(M ^ a ^ w + 0.0, M ^ b ^ w + 0.0, M ^ c ^ w + 0.0, M ^ d ^ w + 0.0).
227+