坐标系 — 告诉别人"你在哪"Coordinate System — Describing "Where You Are"
1.1 为什么需要坐标?1.1 Why Do We Need Coordinates?
VEX 比赛的场地是一个 366cm x 366cm 的正方形。比赛中你要跟队友沟通机器人的位置。The VEX competition field is a 366cm x 366cm square. During a match, you need to communicate your robot's position to your teammates.
如果你说"机器人在左边一点",队友会问:多左?多一点是多少?If you say "the robot is a bit to the left," your teammate will ask: how far left? How much is "a bit"?
所以我们需要一种精确的方式来描述位置 -- 用两个数字:一个表示左右,一个表示前后。这就是坐标。That's why we need a precise way to describe position — using two numbers: one for left-right, one for front-back. This is what coordinates are.
写法是 (x, y)。x 表示左右位置,y 表示前后位置。比如 (100, 200) 的意思是"往右 100cm、往前 200cm"。Written as (x, y). x represents the left-right position, y represents the front-back position. For example, (100, 200) means "100cm to the right, 200cm forward."
1.2 x 和 y1.2 x and y
- x = 左右方向。往右是正数,往左是负数。x = left-right direction. Right is positive, left is negative.
- y = 前后方向。往前是正数,往后是负数。y = front-back direction. Forward is positive, backward is negative.
看下面这个简化的场地俯视图,上面标了几个位置的坐标:Look at this simplified top-down view of the field, with coordinates marked at several positions:
几个要点:Key points:
- 往右走,x 增大;往左走,x 减小Moving right increases x; moving left decreases x
- 往前走(图上是往上),y 增大;往后走(图上是往下),y 减小Moving forward (upward on the diagram) increases y; moving backward (downward) decreases y
- 中心点是 (0, 0),叫做原点The center point is (0, 0), called the origin
在脑子里想象一个方格纸。你站在 (0, 0):Imagine a grid in your head. You're standing at (0, 0):
- 往右走 3 步 -- 你在 (3, 0)Walk 3 steps right — you're at (3, 0)
- 再往前走 2 步 -- 你在 (3, 2)Walk 2 steps forward — you're at (3, 2)
- 再往左走 1 步 -- 你在 (?, 2) 答案是?Walk 1 step left — you're at (?, 2). What's the answer?
1.3 原点和正方向1.3 Origin and Positive Directions
原点就是坐标的起始点 (0, 0)。通常我们把机器人出发的位置设为原点。The origin is the starting point of the coordinate system, (0, 0). We usually set the robot's starting position as the origin.
正方向的约定:The positive direction convention:
- x 正方向 = 往右Positive x = right
- y 正方向 = 往前Positive y = forward
这个约定并不是绝对的 -- 有些代码可能把 y 正方向定义成往后。重要的是:你和你的代码约定一致就行。This convention isn't absolute — some code might define positive y as backward. What matters is: you and your code agree on the same convention.
坐标系没有"标准答案",关键是团队和代码保持一致。我们这里统一用:右 = x 正、前 = y 正。There's no "correct answer" for coordinate systems — the key is consistency within your team and code. We'll use: right = positive x, forward = positive y.