小编Dee*_*ewy的帖子

空间中的旋转向量和C++中的高精度

这是我用C++计算3D旋转的函数,该旋转由围绕轴的辐射角度定义.

 Vector rotate(const Vector& axis, const Vector& input, const double angle)    {
    double norm = 1/axis.norm();

    if(norm != 1)
        axis *= norm;

    double cos = std::cos(angle);
    double mcos = 1 - cos;
    double sin = std::sin(angle);

    double r1[3];
    double r2[3];
    double r3[3];

    double t_x, t_ym t_z;


    r1[0] = cos + std::pow(axis.x, 2)*mcos;
    r1[1] = axis.x*axis.y*mcos - axis.z * sin;
    r1[2] = axis.x*axis.z*mcos - axis.y * sin;

    r2[0] = axis.x*axis.y*mcos + axis.z*sin;
    r2[1] = cos + std::pow(axis.y, 2)*mcos;
    r2[2] = axis.x*axis.z*mcos …
Run Code Online (Sandbox Code Playgroud)

c++ precision

8
推荐指数
1
解决办法
725
查看次数

如何在Unity中为桌面VR应用程序逐帧显示360视频?

是否可以通过事件控制360度视频在时间上向前或向后移动(帧+/- 1),例如按下控制器按钮?

这里的想法是从视频中提取环境.视频不应该播放.按下按钮时,我们可以转到下一个/上一个帧.

有关于此的一些文件吗?我只找到了Skybox-PanoramicBeta.shader.

unity-game-engine virtual-reality 360-panorama 360-virtual-reality

6
推荐指数
1
解决办法
257
查看次数

为什么使用迭代器这种方式有效?

这是一个最小的代码,以重新创建让我怀疑的条件:

#include <map>
#include <string>

int main()
{
  std::map<std::string, std::string> mm;

  mm.emplace("Hi", "asd");
  mm.emplace("Hey", "asd");
  mm.emplace("Hello", "asd");

  std::map<std::string, std::string>::const_iterator it = mm.find("Hey");
  it->second.size();

  // A
  //it->second.replace(0,1,"h");

  //B
  auto u = it->second;
  u.replace(0,1,"h");
}
Run Code Online (Sandbox Code Playgroud)

为什么会出现一个错误,即将常量作为参数传递,以防A万一B?

错误详情:

错误:将'const std :: basic_string'作为'this'参数传递给'std :: basic_string <_CharT,_ Traits,_Alloc>&std :: basic_string <_CharT,_Traits,_Alloc> :: replace(std :: basic_string <_CharT ,_Traits,_Alloc> :: size_type,std :: basic_string <_CharT,_Traits,_Alloc> :: size_type,const _CharT*)[with _CharT = char; _Traits = std :: char_traits; _Alloc = std :: allocator; std :: basic_string …

c++ stl

4
推荐指数
1
解决办法
211
查看次数

管理std容器中的抽象类

经过大量研究后,我仍然不明白如何使用智能指针处理抽象类集合.

以下是我得到的错误:

error: use of deleted function 'std::unique_ptr<_Tp, _Dp>::unique_ptr(const std::unique_ptr<_Tp, _Dp>&) [with _Tp = Shape; _Dp = std::default_delete<Shape>]'
   base_ptr s = shapes.front();

error: no matching function for call to 'std::unique_ptr<Shape>::unique_ptr(Shape&)'
   shapes.push(base_ptr(b));
Run Code Online (Sandbox Code Playgroud)

通过编译最小代码来复制错误(代码可在线获得).

    #include <queue>
    #include <memory>

    class Shape {
    public:
        virtual int getPerimeter() =0;
    };

    typedef std::unique_ptr<Shape> base_ptr;

    class Circle : public Shape {
    public:
        virtual int getPerimeter() { return 1; };
    };

    class Square : public Shape {
    public:
        virtual int getPerimeter() { return 0; };
    }; …
Run Code Online (Sandbox Code Playgroud)

c++ c++11

3
推荐指数
1
解决办法
115
查看次数