Skip to content

Commit 1c2ad8a

Browse files
cyzdzy
1 parent 0b374b6 commit 1c2ad8a

File tree

169 files changed

+122
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

169 files changed

+122
-0
lines changed

Diff for: 大作业/陈昱璋/植物大战僵尸-完整素材/植物大战僵尸-完整素材/res/Zombies/FootballZombie/LostHead.tmp

Whitespace-only changes.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
//头文件要求
2+
#include <cmath>
3+
#include "vector2.h"
4+
5+
//加法
6+
vector2 operator +(vector2 x, vector2 y) {
7+
return vector2(x.x + y.x, x.y + y.y );
8+
}
9+
10+
//减法
11+
vector2 operator -(vector2 x, vector2 y) {
12+
return vector2(x.x - y.x, x.y - y.y);
13+
}
14+
15+
// 乘法
16+
vector2 operator *(vector2 x, vector2 y) {
17+
return vector2(x.x * y.x - x.y * y.y, x.y * y.x + x.x * y.y);
18+
}
19+
20+
// 乘法
21+
vector2 operator *(vector2 y, float x) {
22+
return vector2(x*y.x, x*y.y);
23+
}
24+
25+
vector2 operator *(float x, vector2 y) {
26+
return vector2(x * y.x, x * y.y);
27+
}
28+
29+
//叉积
30+
long long cross(vector2 x, vector2 y) { return x.y * y.x - x.x * y.y; }
31+
32+
//数量积 点积
33+
long long dot(vector2 x, vector2 y) { return x.x * y.x + x.y * y.y; }
34+
35+
//四舍五入除法
36+
long long dv(long long a, long long b) {//注意重名!!!
37+
return b < 0 ? dv(-a, -b)
38+
: (a < 0 ? -dv(-a, b)
39+
: (a + b / 2) / b);
40+
}
41+
42+
//模长平方
43+
long long len(vector2 x) { return x.x * x.x + x.y * x.y; }
44+
45+
//模长
46+
long long dis(vector2 x) { return sqrt(x.x * x.x + x.y * x.y); }
47+
48+
//向量除法
49+
vector2 operator /(vector2 x, vector2 y) {
50+
long long l = len(y);
51+
return vector2(dv(dot(x, y), l), dv(cross(x, y), l));
52+
}
53+
54+
//向量膜
55+
vector2 operator %(vector2 x, vector2 y) { return x - ((x / y) * y); }
56+
57+
//向量GCD
58+
vector2 gcd(vector2 x, vector2 y) { return len(y) ? gcd(y, x % y) : x; }
59+
60+
61+
vector2 calcBezierPoint(float t, vector2 p0, vector2 p1, vector2 p2, vector2 p3) {
62+
float u = 1 - t;
63+
float tt = t * t;
64+
float uu = u * u;
65+
float uuu = uu * u;
66+
float ttt = tt * t;
67+
68+
vector2 p = uuu * p0;
69+
p = p + 3 * uu * t * p1;
70+
p = p + 3 * u * tt * p2;
71+
p = p + ttt * p3;
72+
73+
return p;
74+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#pragma once
2+
3+
//头文件要求
4+
#include <cmath>
5+
6+
struct vector2 {
7+
vector2(int _x=0, int _y=0) :x(_x), y(_y) {}
8+
vector2(int* data) :x(data[0]), y(data[1]){}
9+
long long x, y;
10+
};
11+
12+
//加法
13+
vector2 operator +(vector2 x, vector2 y);
14+
15+
//减法
16+
vector2 operator -(vector2 x, vector2 y);
17+
18+
// 乘法
19+
vector2 operator *(vector2 x, vector2 y);
20+
vector2 operator *(vector2, float);
21+
vector2 operator *(float, vector2);
22+
23+
//叉积
24+
long long cross(vector2 x, vector2 y);
25+
26+
//数量积 点积
27+
long long dot(vector2 x, vector2 y);
28+
29+
//四舍五入除法
30+
long long dv(long long a, long long b);
31+
32+
33+
//模长平方
34+
long long len(vector2 x);
35+
36+
//模长
37+
long long dis(vector2 x);
38+
39+
//向量除法
40+
vector2 operator /(vector2 x, vector2 y);
41+
42+
//向量膜
43+
vector2 operator %(vector2 x, vector2 y);
44+
45+
//向量GCD
46+
vector2 gcd(vector2 x, vector2 y);
47+
48+
vector2 calcBezierPoint(float t, vector2 p0, vector2 p1, vector2 p2, vector2 p3);

0 commit comments

Comments
 (0)