math - A math problem i encountered when trying to make a program
问题描述
A rather simple/complicated math problem I encountered whilst programming. Here's the simplified version of it:
a+c=e
b=absolute value of(X-R)
C=absolute value of(X-r)
R-r?
a,c,e,b,X,R are all known but r isn't.
Edit
if(x-R>0&&x-r>0) {//x-R is B and x-r is C
int Rminusr=C-B;
}else if(x-R>0&&x-r<0) {
int Rminusr=-C-B;
}else if(x-R<0&&x-r>0) {
int Rminusr=B+C;
}else if(x-R<0&&x-r<0) {
int Rminusr=B-C;
}else if(x-R==0) {
int Rminusr=-r+x;
}else if(x-r==0) {
int Rminusr=R-x;
}
this is what I got until i realized that i dont actually know r or X-r
解决方案
这里真的只有一个方程式很重要,因为它是唯一一个涉及到的方程式r
:
c = |X-r|
这意味着以下情况之一为真:
c = X-r
c = -(X-r) = r-X
这反过来意味着它r
具有两个可能的值之一:
r = X-c
r = X+c
您需要引入另一个约束r
以确切知道它是这两个值中的哪一个。
你做这些计算是为了什么?可能还有另一种方法可以实现您的目标。
推荐阅读
- html - jQuery .prop 对我不起作用 我正在尝试在文档加载时选择一个复选框,但它不起作用
- ffmpeg - 使用 ffmpeg 完全 GPU 加速(解码、去隔行、缩放、编码)HLS 可变流
- video - 如何 Fancybox 弹出 Youtube 和 Vimeo 视频自动播放
- javascript - 定制的 ReactJS 热图
- image - 将 Colab 文件覆盖到 GoogleDrive '上传新版本' - 管理版本 - 为了保持相同的共享/复制链接
- javascript - .filter() 中的三元运算符
- python - 不能用电视节目报告
- google-chrome - 仅在刷新后加载 Chrome 扩展程序
- c# - 如何在没有 ServicePointManager.ServerCertificateValidationCallback 的情况下使用自签名 SSL 证书?
- group-by - 是否有火花 SQL 从表中的每个组中获取不同大小的不同子集?