移动3d中的点集 [英] Shift set of points in 3d

查看:136
本文介绍了移动3d中的点集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在3d中有一组点。我通过加入这些点形成一条线。我必须获得另一条线,这是这条线的移位版本,使得结果移动总是在原始线的右边。什么是解决这个问题的方法?如何每次都得到正确的方向向上的向量?

I have a set of points in 3d. I form a line by joining these points. I have to obtain another line which is a shifted version of this line, such that the resultant shift is always to the right of the original line. What would be an approach to solve this problem? How to get the up vectors in the right direction each time?

假设这些点位于球体上。查看球体的顶视图我会想要这样的

Assume these points to lie on a sphere. Looking at the top view of the sphere i would want something like this

/ \ / \ / \ / \

/ \\ / \ / \ / \

/\/\/\/\
/\/\/\/\

第一行是原始的点集,第二行是移位集

The first line is the original set of points and the second one the shifted set

确定我要添加代码

std::vector<osg::Vec3> vertArray; // The array containig the 3d points
std::vector<osg::Vec3> shiftVec; // The array to store the shifted vectors

osg::Vec3 line1, line2, result, upVec, p1, p2, cross1, cross2;

result = vertArray[1] - vertArray[0];
result.normalise();
result = result X upVec; // i am not sure how to get this upvec for general set of   points
shiftVec.push_back(result);

for(unsigned int i = 1; i < vertArray.size() - 1; i++)
{
 line 1 = vertArray[i-1] - vertArray[i];
 line 2 = vertArray[i+1] - vertArray[i];
 line1.normalise();
 line2.normalise();
 upVec = line1 X line2;
 line 1 = line1 X upVec;
 p1 = vertArray[i-1] + line1;
 line 2 = line2 X upVec;
 p2 = vertArray[i+1] + line2;
 cross1 = upVec;
 cross2 = (p2-p1)X line2
 float factor = cross2.lenght()/cross1.length();
 result = p1+line1*factor;
 result = result - vertArray[i];
 shiftVec.push_back(result);
}

result = vertArray[i] - vertArray[i-1];
result.normalise();
result = result X upVec; // i am not sure how to get this upvec for general set of points
shiftVec.push_back(result);


推荐答案

看这里: ECEF< - > ENU coordinates 这可能有助于

我宁愿使用NEH本地北,东,高度(或高度)坐标系

I rather use NEH local North,East,Height(or altitude) coordinate system


  • 类似于罗盘+高度表


  • 然后如果您不在旋转轴方向(ECEF Z轴)向量只是(0,0,6356754.7)-viewer_position (都在ECEF中)

  • 东西向量可以获得 North x(0,0,6356754.7)

  • 它是东或西(取决于你的坐标系和交叉乘法的顺序)

  • 只是视觉上检查,如果错误反转顺序或否定结果

  • 向上(高度或高度)很容易从 Up = North x East Up = North x West

  • 如果错误的方向颠倒顺序或否定结果...

  • it is similar to compass + altimeter
  • if you are not looking in rotation axis direction (ECEF Z-axis) ... on poles
  • then North vector is just (0,0,6356754.7)-viewer_position (all in ECEF)
  • East,West vectors can be obtained as North x (0,0,6356754.7)
  • don`t remember if it is east or west (depends on your coordinate system and cross multiplicants order)
  • just check it visually and if wrong reverse the order or negate result
  • Up vector (Height or Altitude) is easy from this just Up=North x East or Up=North x West
  • again if wrong direction reverse order or negate result ...

[Notes]


  • 6356754.7 [m]是地球极半径

  • 如果您从极点(ECEF Z轴)查看

  • ,则向量北向量和向上向量位于同一轴(相反方向)

  • 这意味着南半球没有东或西(奇点)

  • 通常使用南而不是北

  • 在这种情况下 South =(0,0,-6356754.7)-viewer_position

  • 6356754.7 [m] is earths polar radius
  • if you viewing from poles (ECEF Z-axis)
  • then North vector and Up vector lies on the same axis (in opposite direction)
  • which means there is no east or west (singularity)
  • on south hemisphere is usually used South instead of North
  • in that case South = (0,0,-6356754.7)-viewer_position

这篇关于移动3d中的点集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆