0 / 4 页已完成

三角函数 — 斜着走怎么算?Trigonometry — How to Calculate Diagonal Movement?

▶ 推荐视频▶ Recommended Videos

Trigonometry For Beginners! — The Organic Chemistry Tutor · 21 分钟min · 英文English · 800 万播放的经典三角函数入门Classic trig intro with 8M views

Trig Visualized — 4 分钟min · 英文English · 一张图看懂所有三角函数关系Understand all trig relationships in one diagram

3.1 问题引入3.1 The Problem

机器人朝 30 度方向走了 10cm。问题来了:The robot moves 10cm in the 30-degree direction. Here's the question:

画出来就是一个直角三角形:If you draw it out, it forms a right triangle:

x(右) y(前) 30 度 10cm 5cm(往右) 8.66cm (往前)

斜边是 10cm,其中一个角是 30 度。数学家给这个拆分过程起了个名字:sincosThe hypotenuse is 10cm, and one angle is 30 degrees. Mathematicians gave this splitting process a name: sin and cos.

3.2 sin 和 cos 是什么3.2 What Are sin and cos?

很简单,它们就是"拆分比例":It's simple — they're just "splitting ratios":

核心公式Core Formulas
sin(角度) = 往右走了多少 / 总共走了多少(横向比例)sin(angle) = how far right / total distance (horizontal ratio)
cos(角度) = 往前走了多少 / 总共走了多少(纵向比例)cos(angle) = how far forward / total distance (vertical ratio)

所以:So:

用上面的例子验证:机器人朝 30 度走了 10cmLet's verify with the example above: the robot moves 10cm at 30 degrees

一句话总结One-Line Summary

sin 和 cos 就是把"斜着走"翻译成"往右走了多少 + 往前走了多少"的工具。sin and cos are tools that translate "moving diagonally" into "how far right + how far forward."

动手试试Try It Yourself

不用计算器,猜一猜:Without a calculator, take a guess:

朝 0 度(正前方)走 10 步,sin(0 度) 应该是多少?(提示:完全往前走,往右走了 0 步)Walk 10 steps at 0 degrees (straight ahead). What should sin(0°) be? (Hint: you're going entirely forward, 0 steps to the right)

3.3 常用值参考(不用背,用的时候查这里)3.3 Common Values Reference (No need to memorize — look them up here)

以下数值不需要记住。写代码时电脑会帮你算 sin/cos,这张表只是帮你建立直觉 -- 角度越大,sin 越大,cos 越小。You don't need to memorize these values. The computer calculates sin/cos for you when coding. This table just helps build intuition — as the angle increases, sin gets larger and cos gets smaller.

角度Anglesincos含义Meaning
0 度01完全往前走Moving entirely forward
30 度30°0.50.87主要往前,稍微偏右Mostly forward, slightly right
45 度45°0.710.71往前和往右各一半Equal parts forward and right
60 度60°0.870.5主要往右,稍微偏前Mostly right, slightly forward
90 度90°10完全往右走Moving entirely right

规律很明显:角度越大,sin 越大(越偏右),cos 越小(越不往前)。The pattern is clear: as the angle increases, sin gets larger (more rightward) and cos gets smaller (less forward).

3.4 自己试一试3.4 Try It Yourself

拖动下面的滑块,看看不同角度时 sin 和 cos 怎么变化:Drag the slider below to see how sin and cos change at different angles:

x+ y+ sin = 0.50 cos = 0.87
30 度
sin(角度angle)
0.50
cos(角度angle)
0.87
走 10cm:往右 5.00 cm,往前 8.66 cmMove 10cm: right 5.00 cm, forward 8.66 cm

3.5 为什么定位轮需要 sin/cos?3.5 Why Do Tracking Wheels Need sin/cos?

定位轮测到的是两个信息:Tracking wheels measure two things:

但我们的坐标系需要的是:But our coordinate system needs:

sin 和 cos 就是那个翻译器 -- 把"朝某个方向走了多远"翻译成"x 变了多少、y 变了多少"。sin and cos are the translator — they convert "moved this far in this direction" into "x changed by this much, y changed by this much."

定位轮核心公式预告Tracking Wheel Core Formula Preview

在定位轮的代码里,你会看到这两行:In the tracking wheel code, you'll see these two lines:
deltaX = distance * sin(heading)
deltaY = distance * cos(heading)
现在你知道它们在干什么了。Now you know what they're doing.

检查点Checkpoint
机器人朝 45 度走了 20cm。往右走了多少?(保留 1 位小数)The robot moves 20cm at 45 degrees. How far did it move to the right? (Round to 1 decimal place)
cm