本文整理汇总了C++中Vector4d函数的典型用法代码示例。如果您正苦于以下问题:C++ Vector4d函数的具体用法?C++ Vector4d怎么用?C++ Vector4d使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Vector4d函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: destroy
//---------------------------------------------------------------------------------
bool GlesFullScreenQuad::initialize()
{
destroy();
static Vector4d vertices[] =
{
Vector4d(-1.0f, -1.0f, 0.0f, 0.0f),
Vector4d(-1.0f, 1.0f, 0.0f, 1.0f),
Vector4d( 1.0f, -1.0f, 1.0f, 0.0f),
Vector4d( 1.0f, 1.0f, 1.0f, 1.0f)
};
const uint32_t vertexBufferSize = sizeof(vertices);
glGenBuffers(1, &vertexBuffer_);
glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer_);
CHECK_GLES_ERROR("GlesFullScreenQuad::initialize: glBindBuffer");
glBufferData(GL_ARRAY_BUFFER, vertexBufferSize, vertices, GL_STATIC_DRAW);
CHECK_GLES_ERROR("GlesFullScreenQuad::initialize: glBufferData");
glBindBuffer(GL_ARRAY_BUFFER, 0);
return true;
}
示例2: test_mapstride
void test_mapstride()
{
for(int i = 0; i < g_repeat; i++) {
EIGEN_UNUSED int maxn = 30;
CALL_SUBTEST_1( map_class_vector<Aligned>(Matrix<float, 1, 1>()) );
CALL_SUBTEST_1( map_class_vector<Unaligned>(Matrix<float, 1, 1>()) );
CALL_SUBTEST_2( map_class_vector<Aligned>(Vector4d()) );
CALL_SUBTEST_2( map_class_vector<Unaligned>(Vector4d()) );
CALL_SUBTEST_3( map_class_vector<Aligned>(RowVector4f()) );
CALL_SUBTEST_3( map_class_vector<Unaligned>(RowVector4f()) );
CALL_SUBTEST_4( map_class_vector<Aligned>(VectorXcf(internal::random<int>(1,maxn))) );
CALL_SUBTEST_4( map_class_vector<Unaligned>(VectorXcf(internal::random<int>(1,maxn))) );
CALL_SUBTEST_5( map_class_vector<Aligned>(VectorXi(internal::random<int>(1,maxn))) );
CALL_SUBTEST_5( map_class_vector<Unaligned>(VectorXi(internal::random<int>(1,maxn))) );
CALL_SUBTEST_1( map_class_matrix<Aligned>(Matrix<float, 1, 1>()) );
CALL_SUBTEST_1( map_class_matrix<Unaligned>(Matrix<float, 1, 1>()) );
CALL_SUBTEST_2( map_class_matrix<Aligned>(Matrix4d()) );
CALL_SUBTEST_2( map_class_matrix<Unaligned>(Matrix4d()) );
CALL_SUBTEST_3( map_class_matrix<Aligned>(Matrix<float,3,5>()) );
CALL_SUBTEST_3( map_class_matrix<Unaligned>(Matrix<float,3,5>()) );
CALL_SUBTEST_3( map_class_matrix<Aligned>(Matrix<float,4,8>()) );
CALL_SUBTEST_3( map_class_matrix<Unaligned>(Matrix<float,4,8>()) );
CALL_SUBTEST_4( map_class_matrix<Aligned>(MatrixXcf(internal::random<int>(1,maxn),internal::random<int>(1,maxn))) );
CALL_SUBTEST_4( map_class_matrix<Unaligned>(MatrixXcf(internal::random<int>(1,maxn),internal::random<int>(1,maxn))) );
CALL_SUBTEST_5( map_class_matrix<Aligned>(MatrixXi(internal::random<int>(1,maxn),internal::random<int>(1,maxn))) );
CALL_SUBTEST_5( map_class_matrix<Unaligned>(MatrixXi(internal::random<int>(1,maxn),internal::random<int>(1,maxn))) );
CALL_SUBTEST_6( map_class_matrix<Aligned>(MatrixXcd(internal::random<int>(1,maxn),internal::random<int>(1,maxn))) );
CALL_SUBTEST_6( map_class_matrix<Unaligned>(MatrixXcd(internal::random<int>(1,maxn),internal::random<int>(1,maxn))) );
}
}
示例3: test_mapped_matrix
void test_mapped_matrix()
{
for(int i = 0; i < g_repeat; i++) {
CALL_SUBTEST_1( map_class_vector(Matrix<float, 1, 1>()) );
CALL_SUBTEST_1( check_const_correctness(Matrix<float, 1, 1>()) );
CALL_SUBTEST_2( map_class_vector(Vector4d()) );
CALL_SUBTEST_2( map_class_vector(VectorXd(13)) );
CALL_SUBTEST_2( check_const_correctness(Matrix4d()) );
CALL_SUBTEST_3( map_class_vector(RowVector4f()) );
CALL_SUBTEST_4( map_class_vector(VectorXcf(8)) );
CALL_SUBTEST_5( map_class_vector(VectorXi(12)) );
CALL_SUBTEST_5( check_const_correctness(VectorXi(12)) );
CALL_SUBTEST_1( map_class_matrix(Matrix<float, 1, 1>()) );
CALL_SUBTEST_2( map_class_matrix(Matrix4d()) );
CALL_SUBTEST_11( map_class_matrix(Matrix<float,3,5>()) );
CALL_SUBTEST_4( map_class_matrix(MatrixXcf(internal::random<int>(1,10),internal::random<int>(1,10))) );
CALL_SUBTEST_5( map_class_matrix(MatrixXi(internal::random<int>(1,10),internal::random<int>(1,10))) );
CALL_SUBTEST_6( map_static_methods(Matrix<double, 1, 1>()) );
CALL_SUBTEST_7( map_static_methods(Vector3f()) );
CALL_SUBTEST_8( map_static_methods(RowVector3d()) );
CALL_SUBTEST_9( map_static_methods(VectorXcd(8)) );
CALL_SUBTEST_10( map_static_methods(VectorXf(12)) );
CALL_SUBTEST_11( map_not_aligned_on_scalar<double>() );
}
}
开发者ID:muhammedabdelnasser,项目名称:Vehicle-Steering-Using-Model-Predictive-Control,代码行数:28,代码来源:mapped_matrix.cpp
示例4: Vector
Vector PickObjectTool::GetWorldCoordinates(BaseDraw* bd, const Matrix4d& m, Float x, Float y, Float z)
{
// pick object returns the view-projection matrix. This transforms a point in camera space into clip space.
Int32 l, t, r, b, w, h;
Vector4d pos;
Vector posWorld;
bd->GetFrame(&l, &t, &r, &b);
if (l == r || b == t)
return Vector(0.0);
w = r - l;
h = b - t;
// first, transform the points into clip space
pos.x = (x - Float(l)) / Float(w);
pos.y = (y - Float(t)) / Float(h);
pos.z = z;
pos.w = 1.0;
pos = pos * 2.0f - Vector4d(1.0f);
pos.y = -pos.y;
// apply the inverse view transform
Matrix4d im = !m;
pos = im * pos;
pos.MakeVector3();
// convert it into a 3-tupel
posWorld = bd->GetMg() * GetVector3(pos);
return posWorld;
}
示例5: test_nullary
void test_nullary()
{
CALL_SUBTEST_1( testMatrixType(Matrix2d()) );
CALL_SUBTEST_2( testMatrixType(MatrixXcf(internal::random<int>(1,300),internal::random<int>(1,300))) );
CALL_SUBTEST_3( testMatrixType(MatrixXf(internal::random<int>(1,300),internal::random<int>(1,300))) );
for(int i = 0; i < g_repeat; i++) {
CALL_SUBTEST_4( testVectorType(VectorXd(internal::random<int>(1,300))) );
CALL_SUBTEST_5( testVectorType(Vector4d()) ); // regression test for bug 232
CALL_SUBTEST_6( testVectorType(Vector3d()) );
CALL_SUBTEST_7( testVectorType(VectorXf(internal::random<int>(1,300))) );
CALL_SUBTEST_8( testVectorType(Vector3f()) );
CALL_SUBTEST_8( testVectorType(Vector4f()) );
CALL_SUBTEST_8( testVectorType(Matrix<float,8,1>()) );
CALL_SUBTEST_8( testVectorType(Matrix<float,1,1>()) );
CALL_SUBTEST_9( testVectorType(VectorXi(internal::random<int>(1,300))) );
CALL_SUBTEST_9( testVectorType(Matrix<int,1,1>()) );
}
#ifdef EIGEN_TEST_PART_6
// Assignment of a RowVectorXd to a MatrixXd (regression test for bug #79).
VERIFY( (MatrixXd(RowVectorXd::LinSpaced(3, 0, 1)) - RowVector3d(0, 0.5, 1)).norm() < std::numeric_limits<double>::epsilon() );
#endif
}
示例6: glPushMatrix
void teleop_gui_t::render_link(kinematics::Skeleton* robot,
kinematics::BodyNode *link,
const robot::robot_state_t& state,
Eigen::Vector4d color,
bool use_default_color,
bool draw_limits,
int target_joint)
{
if(!link)
return;
glPushMatrix();
// Do self transform
kinematics::Joint* joint = link->getParentJoint();
for(int i=0; i < joint->getNumTransforms(); ++i) {
joint->getTransform(i)->applyGLTransform(mRI);
}
kinematics::Shape* shape = link->getVisualizationShape();
if(shape && !draw_limits) {
glPushMatrix();
shape->draw(mRI, color, use_default_color);
glPopMatrix();
}
if(shape && draw_limits) {
render_limits(robot, link, state, color, Vector4d(1,0,0,color[3]));
}
// Render subtree
for(int i=0; i < link->getNumChildJoints(); ++i) {
render_link(robot, link->getChildJoint(i)->getChildNode(), state, color,
use_default_color, draw_limits, target_joint);
}
glPopMatrix();
}
示例7: Vector4d
Vector4d Triangle::normal(Vector4d x, Vector4d y, Vector4d z) const {
Vector4d edge1 = y - x;
Vector4d edge2 = z - x;
Vector3d e1 = edge1.head(3);
Vector3d e2 = edge2.head(3);
Vector3d result = e1.cross(e2);
return Vector4d(result(0), result(1), result(2), 0);
}
示例8: Vector4d
Vector4d operator-(const Vector4d & _vec1, const Vector4d & _vec2)
{
Vector4d newvec = Vector4d();
newvec.data[0] = _vec1[0] - _vec2[0];
newvec.data[1] = _vec1[1] - _vec2[1];
newvec.data[2] = _vec1[2] - _vec2[2];
newvec.data[3] = _vec1[3] - _vec2[3];
return newvec;
}
示例9: hat
Matrix4d Sim3::
hat(const Vector7d & v)
{
Matrix4d Omega;
Omega.topLeftCorner<3,3>() = ScSO3::hat(v.tail<4>());
Omega.col(3).head<3>() = v.head<3>();
Omega.row(3) = Vector4d(0., 0., 0., 0.);
return Omega;
}
示例10: Build_CAM4D_Matrix_UVN
void Build_CAM4D_Matrix_UVN(CAM4D_PTR cam, int mode)
{
Matrix4d mt_inv,
mt_uvn;
mt_inv << 1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0.
- cam->pos(0), -cam->pos(1), -cam->pos(2), 1;
if (mode == UVN_MODE_SPHERICAL) {
float phi = cam->dir(0);
float theta = cam->dir(1);
float sin_phi = Fast_Sin(phi);
float cos_phi = Fast_Cos(phi);
float sin_theta = Fast_Sin(theta);
float cos_theta = Fast_Cos(theta);
cam->target(0) = -1 * sin_phi * sin_theta;
cam->target(1) = 1 * cos_phi;
cam->target(2) = 1 * sin_phi * cos_theta;
}
cam->n = cam->target - cam->pos;
Vector3d t1, t2, t3;
t1 = Vector3d(cam->n(0), cam->n(1), cam->n(2));
t2 = Vector3d(0, 1, 0);
t3 = t2.cross(t1);
t2 = t1.cross(t3);
cam->u = Vector4d(t3(0), t3(1), t3(2), 1);
cam->v = Vector4d(t2(0), t2(1), t2(2), 1);
cam->u.normalize();
cam->v.normalize();
cam->n.normalize();
mt_uvn << cam->u(0), cam->v(0), cam->n(0), 0,
cam->u(1), cam->v(1), cam->n(1), 0,
cam->u(2), cam->v(2), cam->n(2), 0,
0, 0, 0, 1;
cam->mcam = mt_inv * mt_uvn;
}
示例11: matrix
Vector4d operator*(const Matrix4x4& matrix, const Vector4d& vector)
{
return Vector4d
(
matrix(0, 0) * vector[0] + matrix(0, 1) * vector[1] + matrix(0, 2) * vector[2] + matrix(0, 3) * vector[3],
matrix(1, 0) * vector[0] + matrix(1, 1) * vector[1] + matrix(1, 2) * vector[2] + matrix(1, 3) * vector[3],
matrix(2, 0) * vector[0] + matrix(2, 1) * vector[1] + matrix(2, 2) * vector[2] + matrix(2, 3) * vector[3],
matrix(3, 0) * vector[0] + matrix(3, 1) * vector[1] + matrix(3, 2) * vector[2] + matrix(3, 3) * vector[3]
);
}
示例12: Vector4d
Vector4d Vector4d::operator-(Vector4d & another){
GLdouble x = v[0] / v[3];
GLdouble y = v[1] / v[3];
GLdouble z = v[2] / v[3];
GLdouble w = v[3];
x = (x - another[0] / another[3]) * w;
y = (y - another[1] / another[3]) * w;
z = (z - another[2] / another[3]) * w;
return Vector4d(x, y, z, w);
}
示例13: tan
Camera::Camera(Camera::CameraType t, const Vector4d &p, const Vector4d &d, const Vector4d &uvnTarget, float nearZ, float farZ,
float fovAngle, float width, float height)
:_type(t)
,_pos(p)
,_direction(d)
,_target(uvnTarget)
,_nearClipZ(nearZ)
,_farClipZ(farZ)
,_fov(fovAngle)
,_viewportWidth(width)
,_viewportHeight(height)
,u(Vector4d(1, 0, 0, 0))
,v(Vector4d(0, 1, 0, 0))
,n(Vector4d(0, 0, 1, 0))
,_worldToCam(Matrix4d::IDENTITY)
,_camToProj(Matrix4d::IDENTITY)
,_projToView(Matrix4d::IDENTITY)
{
_viewportCenterX = (_viewportWidth - 1) / 2;
_viewportCenterY = (_viewportHeight - 1) / 2;
_aspectRadio = _viewportWidth / _viewportHeight;
_viewPlaneWidth = 2;
_viewPlaneHeight = 2/_aspectRadio;
float tanFovDiv2 = tan(DEG_TO_RAD(_fov / 2));
_viewDishH = _viewDish = 0.5 * _viewPlaneWidth * tanFovDiv2;
_viewDishV = 0.5 * _viewPlaneHeight * tanFovDiv2;
if (_fov == 90.0)
{
_rightClipPlane.normal = Vector3d(1, 0, -1);
_leftClipPlane.normal = Vector3d(-1, 0, -1);
_upClipPlane.normal = Vector3d(0, 1, -1);
_downClipPlane.normal = Vector3d(0, -1, -1);
}else
{
_rightClipPlane.normal = Vector3d(_viewDish, 0, -_viewPlaneWidth / 2);
_leftClipPlane.normal = Vector3d(-_viewDish, 0, -_viewPlaneWidth / 2);
_upClipPlane.normal = Vector3d(0, _viewDish, -_viewPlaneWidth / 2);
_downClipPlane.normal = Vector3d(0, -_viewDish, -_viewPlaneWidth / 2);
}
}
示例14: test_stable_norm
void test_stable_norm()
{
for(int i = 0; i < g_repeat; i++) {
CALL_SUBTEST_1( stable_norm(Matrix<float, 1, 1>()) );
CALL_SUBTEST_2( stable_norm(Vector4d()) );
CALL_SUBTEST_3( stable_norm(VectorXd(internal::random<int>(10,2000))) );
CALL_SUBTEST_4( stable_norm(VectorXf(internal::random<int>(10,2000))) );
CALL_SUBTEST_5( stable_norm(VectorXcd(internal::random<int>(10,2000))) );
}
}
示例15: invT
bool Camera::nearClippingPlane(Vector3d *normal, Vector3d *point)
{
// Determine near plane from three coplanar points:
// (http://www.songho.ca/opengl/gl_projectionmatrix.html is a
// helpful resource here.)
// We will convert following points (which are in the near plane)
// from NDC coordinates to object coordinates:
//
// (-1, -1, -1), (1,-1,-1), and (-1,1,-1).
//
// First get the current transformation matrix (T = PM, P is
// projection matrix, M is modelview matrix), which converts
// Object coordinates (O) to NDC coordinates (N) via:
//
// N = T O
//
// These are stored in the private class, no need to query OpenGL
// for them.
const Matrix4d &proj = d->projection.matrix();
const Matrix4d &modv = d->modelview.matrix();
// Now invert the matrix so that we can find our three coplanar
// points in Object coordinates via:
//
// O = Inv(T) N
//
// Calculate T ( = PM ) here, too:
const Matrix4d invT ((proj * modv).inverse());
// Now to get three points and a normal vector:
// (V4toV3DivW converts {x,y,z,w} to {x,y,z}/w)
*point = V4toV3DivW(invT * Vector4d(-1,-1,-1,1) );
const Vector3d p1 ( V4toV3DivW(invT * Vector4d(1,-1,-1,1) ));
const Vector3d p2 ( V4toV3DivW(invT * Vector4d(-1,1,-1,1) ));
// This cross product ensures that the normal points into the
// viewing volume:
*normal = (p2-(*point)).cross(p1-(*point)).normalized();
return true;
}