Last active
January 11, 2026 11:46
-
-
Save ChuanyuXue/1f5eff4047acd04b79d09344d2f8b152 to your computer and use it in GitHub Desktop.
embedded_md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "cells": [ | |
| { | |
| "cell_type": "markdown", | |
| "id": "b08aa304", | |
| "metadata": {}, | |
| "source": [ | |
| "Basically given a angle $\\theta \\in [0, 2\\pi)$ we can get the unit vector for direction\n", | |
| " \n", | |
| " $$\n", | |
| " \\begin{aligned}\n", | |
| " & {dir}_x=\\cos (\\theta) \\\\\n", | |
| " & {dir}_y=\\sin (\\theta)\n", | |
| " \\end{aligned}\n", | |
| " $$\n", | |
| " \n", | |
| " And given two points, we can get the direction from $p_1$ to $p_2$ by:\n", | |
| " \n", | |
| " $$\n", | |
| " \\begin{aligned}\n", | |
| " d x & =x_2-x_1 \\\\\n", | |
| " d y & =y_2-y_1 \\\\\n", | |
| " \\text { distance } & =\\sqrt{d x^2+d y^2}\n", | |
| " \\end{aligned}\n", | |
| " $$\n", | |
| " \n", | |
| " To get the direction (unit vector), we divide the difference by the distance:\n", | |
| " \n", | |
| " $$\n", | |
| " \\begin{aligned}\n", | |
| " {dir}_x & =d x / \\text { distance } \\\\\n", | |
| " {dir}_y & =d y / \\text { distance }\n", | |
| " \\end{aligned}\n", | |
| " $$" | |
| ] | |
| } | |
| ], | |
| "metadata": { | |
| "language_info": { | |
| "name": "python" | |
| } | |
| }, | |
| "nbformat": 4, | |
| "nbformat_minor": 5 | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment