在处理sin/cos/tan/acos时,有没有人看到过这种奇怪的价值?数学的东西?
=== WEIRD VALUE ===
-1.#IND00
=====================
void inverse_pos(double x, double y, double& theta_one, double& theta_two)
{
// Assume that L1 = 350 and L2 = 250
double B = sqrt(x*x + y*y);
double angle_beta = atan2(y, x);
double angle_alpha = acos((L2*L2 - B*B - L1*L1) / (-2*B*L1));
theta_one = angle_beta + angle_alpha;
theta_two = atan2((y-L1*sin(theta_one)), (x-L1*cos(theta_one)));
}
Run Code Online (Sandbox Code Playgroud)
这是我正在处理的代码.
在特定条件下 - 例如当x和y为10和10时, 此代码将-1.#IND00存储到theta_one和theta_two中.
它看起来不像字符或数字:(
毫无疑问,atan2/acos/stuff是问题所在.
但问题是,try和catch不起作用,因为那些双变量已经成功地存储了一些值.
此外,以下计算永远不会抱怨它,永远不会破坏程序!
我正在考虑强制以某种方式使用此值并使整个程序崩溃...所以我可以捕获此错误..
除了这个想法,我不知道 如何检查这些theta_one和theta_two变量是否存储了这个疯狂的值.
有什么好主意吗?
先感谢您..
在我的ViewDidLoad中,我尝试了类似的东西,但它不起作用:
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(10,2,60,14)];
label.autoresizingMask = UIViewAutoresisingFlecibleWidth;
[self.navigationController.navigationBar addSubview:label];
Run Code Online (Sandbox Code Playgroud)
我想在NavigationBar的左侧部分显示一个标签.或者可能更改navigationBar.title位置
谢谢,
无法从响应中获取"位置"标题.Wireshark说我有一个:
地点:http://*/index.html#0; sid = 865a84f0212a3a35d8e9d5f68398e535
但
NSHTTPURLResponse *hr = (NSHTTPURLResponse*)response;
NSDictionary *dict = [hr allHeaderFields];
NSLog(@"HEADERS : %@",[dict description]);
Run Code Online (Sandbox Code Playgroud)
产生这个:
HEADERS : {
Connection = "keep-alive";
"Content-Encoding" = gzip;
"Content-Type" = "text/html";
Date = "Thu, 25 Mar 2010 08:12:08 GMT";
"Last-Modified" = "Sat, 29 Nov 2008 15:50:54 GMT";
Server = "nginx/0.7.59";
"Transfer-Encoding" = Identity;
}
Run Code Online (Sandbox Code Playgroud)
没有位置.怎么弄?我需要这个"sid"的东西.
我想从字符串中检索连续的8位数.
"hello world,12345678anything else"
Run Code Online (Sandbox Code Playgroud)
应该返回12345678结果(两者之间的空格是可选的).
但这不应该返回任何东西:
"hello world,123456789anything else"
Run Code Online (Sandbox Code Playgroud)
因为它有9位数,所以我只需要8位数单位.
System.IO.Path在.NET中,使用它是非常笨拙的.在我的各种项目中,我遇到保持其要求使用重复的,繁琐,因而容易出错的代码片段相同的使用场景Path.Combine,Path.GetFileName,Path.GetDirectoryName,String.Format,等场景,如:
Package{0}.zip")\(因为它们不适用于Mono上的Linux)在开始编写我自己的PathBuilder类或类似的东西之前:C#中有这样一个好的(并且经过验证的)开源实现吗?
更新:好的,只是说明我的意思:
string zipFileName = Path.GetFileNameWithoutExtension(directoryName) + ".zip";
zipFileName = Path.Combine(
Path.GetDirectoryName(directoryName),
zipFileName);
Run Code Online (Sandbox Code Playgroud)
一个更好的流畅API可能如下所示:
Path2 directoryName = "something";
Path2 zipFileName = directoryName.Extension("zip");
Run Code Online (Sandbox Code Playgroud)
或者在构建路径时:
Path2 directoryName = "something";
Path2 directory2 = directoryName.Add("subdirectory")
.Add("Temp").Add("myzip.zip");
Run Code Online (Sandbox Code Playgroud)
代替
string directory2 = Path.Combine(Path.Combine(Path.Combine(
directoryName, "subdirectory"), "Temp"), "myzip.zip");
Run Code Online (Sandbox Code Playgroud)
我实际上在过去实现了类似的东西,但是在一个单独的项目中.我现在决定将它重新用作一个独立的C#类,在我的其他项目中在VisualStudio中添加"as link".这不是一个最干净的解决方案,但我想它会做到.如果您有兴趣,可以在这里查看代码.
我正在尝试将此数据类型放在Haskell集中,但我不想给它一个Ord的一般实例.所以我想在y-coördinate上给这个集合订购,但没有实例Ord Vector.这可能吗?
data Vector = V
{ x :: Double
, y :: Double
} deriving (Eq)
Run Code Online (Sandbox Code Playgroud) 如何使用C#将单元格聚焦到Excel VSTO中?
如何在VSTO中使用C#选择第一个单元?
请帮忙代码......
我正在使用InnoSetup来创建我的应用程序安装程序,并设置"SetupLogging = yes"标志以始终在%TEMP%目录中创建一个setup-log文件.这适用于安装过程.不幸的是,InnoSetup在卸载应用程序时不会创建这样的日志文件.
是否有标志/可能强制InnoSetup也创建卸载日志文件?
我正在尝试使用openmp通过std :: set多线程循环.当我写下面的代码 -
#pragma omp parallel for
for (std::set<A>::const_iterator i = s.begin(); i != s.end(); ++i) {
const A a = *i;
operate(a);
}
Run Code Online (Sandbox Code Playgroud)
我收到此错误:
error: invalid type for iteration variable 'i'
error: invalid controlling predicate
error: invalid increment expression.
Run Code Online (Sandbox Code Playgroud)
是否有另一种正确的方法来使用openmp迭代std容器?
我知道我可以使用int i和迭代0到s.size()迭代器或operator[]循环体,但这看起来不那么干净.
我正在使用Eclipse 3.4的Google Application Engine插件,我在我的项目中添加了单元测试.单元测试位于名为source的源文件夹中tests,与源文件夹分开src.但是,在生成的war/classes中,测试类存在.
反正是不是将测试类放在生成的war/classes目录中?
谢谢.
java eclipse google-app-engine unit-testing google-eclipse-plugin
c# ×2
c++ ×2
objective-c ×2
.net ×1
angle ×1
eclipse ×1
excel-2007 ×1
exception ×1
haskell ×1
inno-setup ×1
installation ×1
installer ×1
iphone ×1
java ×1
math ×1
openmp ×1
path ×1
php ×1
regex ×1
set ×1
stl ×1
unit-testing ×1
vsto ×1