我将一个形状表示为3D中的一组坐标,我试图围绕一个轴旋转整个对象(在这种情况下是Z轴,但是一旦我开始工作,我想绕所有三个旋转) .
我用旋转矩阵写了一些代码来做到这一点:
//Coord is a 3D vector of floats
//pos is a coordinate
//angles is a 3d vector, each component is the angle of rotation around the component axis
//in radians
Coord<float> Polymers::rotateByMatrix(Coord<float> pos, const Coord<float> &angles)
{
float xrot = angles[0];
float yrot = angles[1];
float zrot = angles[2];
//z axis rotation
pos[0] = (cosf(zrot) * pos[0] - (sinf(zrot) * pos[1]));
pos[1] = (sinf(zrot) * pos[0] + cosf(zrot) * pos[1]);
return pos;
}
Run Code Online (Sandbox Code Playgroud)
下图显示了在尝试旋转之前我试图旋转的对象(向下看Z轴),每个小球体表示我正在尝试旋转的坐标之一
alt text http://www.cs.nott.ac.uk/~jqs/notsquashed.png
通过以下代码为对象执行旋转: …
所以我有一个User表和一个带有User hasMany Histories的History表,我正在尝试在user表上实现分页.
我的问题是我有搜索,一些可以搜索的东西是历史表中的东西.有没有办法根据hasMany关联的表中的数据过滤分页结果?Containable,最初看起来像一个解决方案,允许这样的过滤,但只在检索相关数据,而不是记录本身(除非我遗漏了什么?)
有没有人必须解决这个问题?
我有以下代码:
var entityConnection = (System.Data.EntityClient.EntityConnection)c.Connection;
DbConnection conn = entityConnection.StoreConnection;
ConnectionState initialState = conn.State;
List<Jobs> list = new List<Jobs>();
int id = 0;
try
{
if (initialState != ConnectionState.Open)
conn.Open();
using (DbCommand cmd = conn.CreateCommand())
{
cmd.CommandText = sql;
reader = cmd.ExecuteReader();
int count = 0;
while (reader.Read())
{
id = int.Parse(reader[0].ToString());
list.Add(db.Jobs.Where(x => x.JobId == id).First());
//count++;
//if (count == 150) break;
reader.NextResult();
}
}
}
Run Code Online (Sandbox Code Playgroud)
我收到一个错误说:"system.invalidoperationexception:读取器关闭时调用NextResult的无效尝试"
但事情是我没有关闭读者,但是当我删除这一行:
list.Add(db.Jobs.Where(x => x.JobId == id).First());
Run Code Online (Sandbox Code Playgroud)
一切正常!但这对我来说是无用的,因为我需要从阅读器填充一个列表对象,如果我不能这样做 - 那么我就无法阅读该表了!(ps我正在避免使用sqldatareader并使用dbdatareader,因为它与我联系使用实体框架进行上述调用)
我有一个简单的容器:
template <class nodeType> list {
public:
struct node {
nodeType info;
node* next;
};
//...
};
Run Code Online (Sandbox Code Playgroud)
现在,有一个函数被调用_search,它搜索列表并返回对匹配的节点的引用.现在,当我指的是函数的返回类型时,我认为它应该是list<nodeType>::node*.这是正确的吗?当我定义函数内联时,它完美地工作:
template <class nodeType> list {
public:
struct node {
nodeType info;
node* next;
};
node* _search {
node* temp;
// search for the node
return temp;
}
};
Run Code Online (Sandbox Code Playgroud)
但是,如果我在课外定义函数,
template <class nodeType> list<nodeType>::node* list<nodeType>::_search() {
//function
}
Run Code Online (Sandbox Code Playgroud)
它不起作用.编译器给出了错误说法Expected constructor before list<nodeType>::_search或其他内容.错误与此类似.我目前没有可以测试它的机器.
任何帮助都是真诚的感谢.
我试图通过编写一个简单的文件副本util来学习haskell:
main = do
putStr "Source: "
srcPath <- getLine
putStr "Destination: "
destPath <- getLine
putStrLn ("Copying from " ++ srcPath ++ " to " ++ destPath ++ "...")
contents <- readFile srcPath
writeFile destPath contents
putStrLn "Finished"
Run Code Online (Sandbox Code Playgroud)
这让我感到高兴
GHCi, version 6.10.4: http://www.haskell.org/ghc/ :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer ... linking ... done.
Loading package base ... linking ... done.
[1 of 1] Compiling Main ( D:\Test.hs, interpreted )
D:\Test.hs:8:22: Not in …Run Code Online (Sandbox Code Playgroud) 这可能是一个重复的问题,因为我不知道用短语搜索查询.我正在Java中创建一个类似Zork的文本游戏,角色移动到彼此连接的不同房间.我希望能够列出玩家可用于此房间的所有选项.
例如,房间A连接到B的东边,B连接到A的西边,C的南面,D的北面,依此类推.
我应该使用什么数据结构,或者我应该如何尽可能有效地实现它?
做这样的事情时:
Response.Clear();
Response.OutputStream.Write(buffer, 0, buffer.Length);
Response.ContentType = "audio/mpeg";
Response.Flush();
Run Code Online (Sandbox Code Playgroud)
下载的文件名是"Default.aspx".如何将其更改为"a.mp3"?
我用zend表格注册了表格
$password = new Zend_Form_Element_Password('password');
$password->setLabel($this->_translate->_("Password:"))
->setRequired(true)
->addValidator('stringLength', true, array(4, 32));
$confirmPassword = new Zend_Form_Element_Password('confirmpassword');
$confirmPassword->setLabel($this->_translate->_("Confirm Password:"))
->setRequired(true);
Run Code Online (Sandbox Code Playgroud)
我在控制器中控制密码和确认密码.如果密码和确认密码不匹配,请在confirmmpassword文本框下添加错误消息.我怎样做?
同一台机器上的两个应用程序可以绑定到同一个端口和IP地址吗?更进一步,一个应用程序可以收听来自某个IP和另一个远程IP的请求吗?我知道我可以有一个应用程序从两个线程(或叉子)开始有类似的行为,但两个没有任何共同点的应用程序可以做同样的事情吗?
在errno.h,这个变量被声明为extern int errno;我的问题是,errno在一些调用之后检查值是否安全或在多线程代码中使用perror()是否安全.这是一个线程安全变量吗?如果没有,那么替代方案是什么?
我在x86架构上使用linux和gcc.