初中几何知识复习,已知直角三角形角度和邻边长求对边长

我相信在面对涉及到几何运算的程序问题时不需要打草稿直接敲出正确代码的大神是存在的,当然我目前不是。

最近遇到一个实际问题,需要用到初中学过的三角函数知识来解决,把问题用三角函数来描述就是在一个直角三角形中,已知一个角α的角度,和角α的邻边长a,求角α的对边长b.

立马想到肯定是用tan这个函数,虽然我忘记了叫什么,百度才想起来叫做正切函数,恩,算算我入行到现在6,7年时间,基本上都是使用atan2。tan这个函数貌似总共没用到三次,你还别不信,游戏前端开发大部分还是在写逻辑,写数学算法的时候不多。

两个要点:

1,tan(α的弧度) = 对边长b / 领边长a

2,弧度 = 角度 * PI / 180

那么用代码(js)写答案就是b = Math.tan(α * Math.PI / 180) * a .

时间: 2024-08-02 15:12:56

初中几何知识复习,已知直角三角形角度和邻边长求对边长的相关文章

二叉树遍历 已知中序后序遍历求前序遍历

已知中序.后序遍历求前序遍历的方法和已知前序.中序遍历求后序遍历的方法类似寻找根节点, 然后把中序遍历分成左右两个子树,有如此不断递归.很多文章介绍,不再累述. #include <iostream> #include <cstdio> #include <queue> #include <cstring> using namespace std; const int MAXN = 100; struct Node { char value; Node *l

已知三个点坐标,求由这三个点构成的多边形的最大面积。

给出A(x0, y0) B(x1, y1) C(x2, y2) 1.求3边a,b,c 2. 先求外接圆半径.(一定存在) 海伦公式 + 正弦定理   得  R = a * b * c / (4 * S)   S = sqrt(q * (q - a) * (q - b) * (q -c));  q = (a + b + c) / 2; -----因为是正多边形. 那么只要求出一边与两半径围成的面积 * N 就好. 3. 余弦定理 求3个角. 求最大公约数就是  正多边形 每一份   最小的角度.

PAT A1020——已知后序中序遍历求层序遍历

1020 Tree Traversals Suppose that all the keys in a binary tree are distinct positive integers. Given the postorder and inorder traversal sequences, you are supposed to output the level order traversal sequence of the corresponding binary tree. Input

二叉树遍历 ——已知后序,中序求层序 A1020.(25)

若直接DFS递归求解,会栈溢出 #include <cstdio> #include <cstring> #include <queue> #include <algorithm> using namespace std; const int maxn=50; struct node{ int data; node* lchild; node* rchild; }; int pre[maxn],in[maxn],post[maxn];//先序,中序,后序 i

已知平行四边形的三个点求第四个点

Long time ago Alex created an interesting problem about parallelogram. The input data for this problem contained four integer points on the Cartesian plane, that defined the set of vertices of some non-degenerate (positive area) parallelogram. Points

已知一个3 * 3矩阵,求对角线元素的和,并且中间的只可以加一次

这道题有很多的方法,这是自己想出来的一个规律 例如 行    列   1  2 3 1 1  2  3 2 4  5  6 3 7  8  9 这里可以发现规律行和列的差 可以分辨出对角线的元素的位置,可以很快地找到 例如当   abs(行 - 列) != 1,才是对角线的元素,对于中间的元素只相加一次的话, 可以每次输入就相加.可以解决问题. 代码: #include <iostream> #include <cstdio> #include <cmath> usin

【已知中序后序二叉树求前序二叉树】

int InOrder[1000], PosterOrder[1000]; typedef struct BiTNode { int data; struct BiTNode *LChild, *RChild; } BiTNode, *BiTree; int find(int *InOrder, int &x, int n) { for(int i = 0; i< n; ++i) {if(InOrder[i] == x) return i;} return -1; } void PreOrd

九度1078(二叉树已知先序和中序求后序)

题目链接:点击打开链接 解题思路: 很不错的一道题.用递归的方法求解.每次对两个序列进行递归,求得左子树的先序/中序,右子树的先序/中序.把树建好后调用递归输出后序即可 完整代码: #include <iostream> #include <cstdio> #include <string> using namespace std; string fir , mid; typedef struct Node { char ch; struct Node *l; stru

三角形已知三个点坐标,求外心坐标的公式

设三个点坐标为:(x1, y1), (x2, y2), (x3, y3).外心坐标为:(a, b). 原文地址:https://www.cnblogs.com/565261641-fzh/p/8111671.html