本文整理汇总了C++中dMatrix类的典型用法代码示例。如果您正苦于以下问题:C++ dMatrix类的具体用法?C++ dMatrix怎么用?C++ dMatrix使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了dMatrix类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: viterbiDecoding
void Gradient::viterbiDecoding(Beliefs bel, iVector& ystar, dMatrix& pystar)
{
int nbNodes, nbStates, xi, yi;
double max_val;
nbNodes = (int)bel.belStates.size();
nbStates = 0;
if(nbNodes > 0)
nbStates = bel.belStates[0].getLength();
ystar.create(nbNodes);
pystar.create(nbNodes,nbStates);
// Viterbi decoding
for( xi=0; xi<nbNodes; xi++) {
ystar.setValue(xi, 0);
max_val = bel.belStates[xi][0];
pystar.setValue(0, xi, bel.belStates[xi][0]);
for( yi=1; yi<nbStates; yi++) {
pystar.setValue(yi, xi, bel.belStates[xi][yi]);
if(max_val < bel.belStates[xi][yi]) {
ystar.setValue(xi,yi);
max_val = bel.belStates[xi][yi];
}
}
}
}
开发者ID:yalesong,项目名称:hCRF-light,代码行数:27,代码来源:gradient.cpp
示例2: Mul
void BLASInterface::Mul(const dMatrix& A,const dMatrix& B,dMatrix& X)
{
X.resize(A.m,B.n);
X.setZero();
if(X.isRowMajor()) std::swap(X.istride,X.jstride);
Madd(A,B,X);
}
开发者ID:HargisJ,项目名称:KrisLibrary,代码行数:7,代码来源:BLASInterface.cpp
示例3: BakeTransform
void dRigidbodyNodeInfo::BakeTransform (const dMatrix& transform)
{
// SetTransform (transform.Inverse4x4() * GetTransform() * transform);
dNodeInfo::BakeTransform (transform);
m_centerOfMass = transform.UnrotateVector(m_centerOfMass);
m_massMatrix = transform.UnrotateVector(m_massMatrix);
m_velocity = transform.RotateVector(m_velocity);
}
开发者ID:Hurleyworks,项目名称:newton-dynamics,代码行数:9,代码来源:dRigidbodyNodeInfo.cpp
示例4: transpose
dMatrix transpose(dMatrix m){
dMatrix t(m[0].size(), dVector(m.size()));
for (int i = 0; i < m.size(); i++){
for( int j = 0; j < m[0].size(); j++){
t[i][j] = m[j][i];
}
}
return t;
}
开发者ID:tfc2,项目名称:if680,代码行数:9,代码来源:util.cpp
示例5: point
void MSNewton::Servo::adjust_pin_matrix_proc(JointData* joint_data, dMatrix& pin_matrix) {
dMatrix matrix;
dVector centre;
NewtonBodyGetMatrix(joint_data->child, &matrix[0][0]);
NewtonBodyGetCentreOfMass(joint_data->child, ¢re[0]);
centre = matrix.TransformVector(centre);
centre = pin_matrix.UntransformVector(centre);
dVector point(0.0f, 0.0f, centre.m_z);
pin_matrix.m_posit = pin_matrix.TransformVector(point);
}
开发者ID:chegarty3,项目名称:MSPhysics,代码行数:10,代码来源:msp_joint_servo.cpp
示例6: GetCoordinates
dMatrix clSpline::GetCoordinates(const dMatrix &uSpec)
{
dMatrix coord;
if(uSpec.GetNumberColumns() != 1 || uSpec.GetNumberRows() == 0)
{
throw clException("clSpline", "GetCoordinates", "Invalid dimensions of matrix uSpec.");
}
else
{
coord.SetNumberRows(uSpec.GetNumberRows());
coord.SetNumberColumns(3);
if(!initialised)
{
Initialise();
}
// Do for all specified u's
for(int i=1; i<=uSpec.GetNumberRows(); i++)
{
if(uSpec(i, 1) < 0 || uSpec(i, 1) > 1)
{
throw clException("clSpline", "GetCoordinates", "Invalid value for uSpec.");
}
else
{
// Now find the position of uSpec
double uu = uSpec(i, 1)*GetSplineLength();
int j = 1;
while((uu - u(j+1, 1) > 0) && (j<u.GetNumberRows()-1))
{
j++;
}
// Now calculate the coefficients
double A = (u(j+1, 1)-uu)/(u(j+1, 1)-u(j,1));
double B = 1-A;
double C = (A*A*A-A)/6 * (u(j+1, 1)-u(j, 1))*(u(j+1, 1)-u(j, 1));
double D = (B*B*B-B)/6 * (u(j+1, 1)-u(j, 1))*(u(j+1, 1)-u(j, 1));
// Finally calculate the coordinates
coord.SetElement(i, 1, A*X(j, 1) + B*X(j+1, 1) + C*X2(j, 1) + D*X2(j+1, 1));
coord.SetElement(i, 2, A*Y(j, 1) + B*Y(j+1, 1) + C*Y2(j, 1) + D*Y2(j+1, 1));
coord.SetElement(i, 3, A*Z(j, 1) + B*Z(j+1, 1) + C*Z2(j, 1) + D*Z2(j+1, 1));
}
}
}
return (coord);
}
开发者ID:hklaufus,项目名称:GridLab,代码行数:52,代码来源:spline.cpp
示例7: multiplicacaoNN
dMatrix multiplicacaoNN(const dMatrix m1, const dMatrix m2)
{
int m1l = m1.size(), m1c = m1[0].size(), m2l=m2.size(), m2c = m2[0].size();
dMatrix matrix(m1l, dVector(m2c, 0));
for (int l = 0; l < m1l; l++){
for (int c = 0; c < m1c; c++){
for (int k = 0; k < m1c; k++){
matrix[l][c] += m1[l][k] * m2[k][c];
}
}
}
return matrix;
}
开发者ID:tfc2,项目名称:if680,代码行数:13,代码来源:util.cpp
示例8: tmp
void dMeshNodeInfo::BakeTransform (const dMatrix& transform)
{
dVector scale;
dMatrix stretchMatrix;
// dMatrix matrix (m_matrix * transform);
// matrix.PolarDecomposition (m_matrix, scale, stretchMatrix);
// matrix = dMatrix (GetIdentityMatrix(), scale, stretchMatrix);
dMatrix tmp (m_matrix);
dMatrix matrix (transform.Inverse4x4() * m_matrix * transform);
matrix.PolarDecomposition (m_matrix, scale, stretchMatrix);
matrix = transform * dMatrix (GetIdentityMatrix(), scale, stretchMatrix);
int pointCount = NewtonMeshGetPointCount (m_mesh);
int pointStride = NewtonMeshGetPointStrideInByte (m_mesh) / sizeof (dFloat);
dFloat* const points = NewtonMeshGetPointArray (m_mesh);
matrix.TransformTriplex(points, pointStride * sizeof (dFloat), points, pointStride * sizeof (dFloat), pointCount);
dFloat* const normals = NewtonMeshGetNormalArray(m_mesh);
dMatrix rotation (matrix.Inverse4x4().Transpose() * matrix);
rotation.m_posit = dVector (0.0f, 0.0f, 0.0f, 1.0f);
rotation.TransformTriplex(normals, pointStride * sizeof (dFloat), normals, pointStride * sizeof (dFloat), pointCount);
int vertexCount = NewtonMeshGetVertexCount (m_mesh);
int vertexStride = NewtonMeshGetVertexStrideInByte (m_mesh) / sizeof (dFloat);
dFloat* const vertex = NewtonMeshGetVertexArray (m_mesh);
matrix.TransformTriplex(vertex, vertexStride * sizeof (dFloat), vertex, vertexStride * sizeof (dFloat), vertexCount);
}
开发者ID:ak4hige,项目名称:myway3d,代码行数:30,代码来源:dMeshNodeInfo.cpp
示例9: diff_unary
double segment::diff_unary(const dMatrix M, int c1, int c2)
{
double val = 0;
for( int r=0; r<M.getHeight(); r++ )
val += fabs( M(r,c1) - M(r,c2) );
return val;
}
开发者ID:apoliver,项目名称:hCRF-light,代码行数:7,代码来源:Segment.cpp
示例10: AddPolygonFromObject
void ConvexApproximationObject::AddPolygonFromObject(INode* const node, ObjectState* const os, NewtonMesh* const meshOut, const dMatrix& matrix)
{
BOOL needDel = FALSE;
PolyObject* const poly = GetPolyObject (os, needDel);
if (poly) {
float polygon[32][12];
memset (polygon, 0, sizeof (polygon));
MNMesh& maxMesh = poly->GetMesh();
int facesCount = maxMesh.FNum();
int vertexCount = maxMesh.VNum();
if (facesCount && vertexCount) {
for (int i = 0; i < facesCount; i ++) {
MNFace* const face = maxMesh.F(i);
for (int j = 0; j < face->deg; j ++) {
int index = face->vtx[j];
Point3 p (maxMesh.P(index));
dVector v (matrix.TransformVector(dVector (p.x, p.y, p.z, 0.0f)));
polygon[j][0] = v.m_x;
polygon[j][1] = v.m_y;
polygon[j][2] = v.m_z;
}
NewtonMeshAddFace(meshOut, face->deg, &polygon[0][0], 12 * sizeof (float), 0);
}
}
}
if (needDel) {
delete poly;
}
}
开发者ID:Hurleyworks,项目名称:newton-dynamics,代码行数:33,代码来源:ConvexApproximation.cpp
示例11: multiplicacaoN1
dVector multiplicacaoN1(const dMatrix &m1, const dVector &v2)
{
dVector vetor (m1[0].size());
for (int i = 0; i < m1.size(); ++i)
for (int j = 0; j < m1[0].size(); ++j)
vetor[i] += m1[i][j] * v2[j];
return vetor;
}
开发者ID:tfc2,项目名称:if680,代码行数:8,代码来源:util.cpp
示例12: x
void dCustomJoint::dDebugDisplay::DrawFrame(const dMatrix& matrix)
{
dVector o0(matrix.m_posit);
dFloat size = 0.25f;
dVector x(matrix.m_posit + matrix.RotateVector(dVector(size, 0.0f, 0.0f, 0.0f)));
SetColor(dVector (1.0f, 0.0f, 0.0f));
DrawLine (matrix.m_posit, x);
dVector y(matrix.m_posit + matrix.RotateVector(dVector(0.0f, size, 0.0f, 0.0f)));
SetColor(dVector (0.0f, 1.0f, 0.0f));
DrawLine (matrix.m_posit, y);
dVector z(matrix.m_posit + matrix.RotateVector(dVector(0.0f, 0.0f, size, 0.0f)));
SetColor(dVector (0.0f, 0.0f, 1.0f));
DrawLine (matrix.m_posit, z);
}
开发者ID:fly-man-,项目名称:newton-dynamics,代码行数:17,代码来源:dCustomJoint.cpp
示例13: GetBoundingBox
dBoundingBox ParticlePrimitive::GetBoundingBox(const dMatrix &space)
{
dBoundingBox box;
for (vector<dVector,FLX_ALLOC(dVector) >::iterator i=m_VertData->begin(); i!=m_VertData->end(); ++i)
{
box.expand(space.transform(*i));
}
return box;
}
开发者ID:Left-handedCatchersGlove,项目名称:fluxus,代码行数:9,代码来源:ParticlePrimitive.cpp
示例14: dAssert
dQuaternion::dQuaternion (const dMatrix &matrix)
{
enum QUAT_INDEX
{
X_INDEX=0,
Y_INDEX=1,
Z_INDEX=2
};
static QUAT_INDEX QIndex [] = {Y_INDEX, Z_INDEX, X_INDEX};
dFloat trace = matrix[0][0] + matrix[1][1] + matrix[2][2];
dAssert (((matrix[0] * matrix[1]) % matrix[2]) > 0.0f);
if (trace > dFloat(0.0f)) {
trace = dSqrt (trace + dFloat(1.0f));
m_q0 = dFloat (0.5f) * trace;
trace = dFloat (0.5f) / trace;
m_q1 = (matrix[1][2] - matrix[2][1]) * trace;
m_q2 = (matrix[2][0] - matrix[0][2]) * trace;
m_q3 = (matrix[0][1] - matrix[1][0]) * trace;
} else {
QUAT_INDEX i = X_INDEX;
if (matrix[Y_INDEX][Y_INDEX] > matrix[X_INDEX][X_INDEX]) {
i = Y_INDEX;
}
if (matrix[Z_INDEX][Z_INDEX] > matrix[i][i]) {
i = Z_INDEX;
}
QUAT_INDEX j = QIndex [i];
QUAT_INDEX k = QIndex [j];
trace = dFloat(1.0f) + matrix[i][i] - matrix[j][j] - matrix[k][k];
trace = dSqrt (trace);
dFloat* const ptr = &m_q1;
ptr[i] = dFloat (0.5f) * trace;
trace = dFloat (0.5f) / trace;
m_q0 = (matrix[j][k] - matrix[k][j]) * trace;
ptr[j] = (matrix[i][j] + matrix[j][i]) * trace;
ptr[k] = (matrix[i][k] + matrix[k][i]) * trace;
}
#if _DEBUG
dMatrix tmp (*this, matrix.m_posit);
dMatrix unitMatrix (tmp * matrix.Inverse());
for (int i = 0; i < 4; i ++) {
dFloat err = dAbs (unitMatrix[i][i] - dFloat(1.0f));
dAssert (err < dFloat (1.0e-3f));
}
dFloat err = dAbs (DotProduct(*this) - dFloat(1.0f));
dAssert (err < dFloat(1.0e-3f));
#endif
}
开发者ID:DevO2012,项目名称:PEEL,代码行数:57,代码来源:dQuaternion.cpp
示例15: SetMatrix
void GLSLShader::SetMatrix(const string &name, dMatrix &m)
{
#ifdef GLSL
if (!m_Enabled) return;
GLuint param = glGetUniformLocation(m_Program, name.c_str());
glUniformMatrix4fv(param, 1, GL_FALSE, m.arr());
#endif
}
开发者ID:Left-handedCatchersGlove,项目名称:fluxus,代码行数:9,代码来源:GLSLShader.cpp
示例16: CalculateAABB
void CalculateAABB (const NewtonCollision* const collision, const dMatrix& matrix, dVector& minP, dVector& maxP)
{
for (int i = 0; i < 3; i ++) {
dVector support(0.0f);
dVector dir (0.0f);
dir[i] = 1.0f;
dVector localDir (matrix.UnrotateVector (dir));
NewtonCollisionSupportVertex (collision, &localDir[0], &support[0]);
support = matrix.TransformVector (support);
maxP[i] = support[i];
localDir = localDir.Scale (-1.0f);
NewtonCollisionSupportVertex (collision, &localDir[0], &support[0]);
support = matrix.TransformVector (support);
minP[i] = support[i];
}
}
开发者ID:MADEAPPS,项目名称:newton-dynamics,代码行数:18,代码来源:PhysicsUtils.cpp
示例17: SetConeAngle
CustomLimitBallAndSocket::CustomLimitBallAndSocket(const dMatrix& childPinAndPivotFrame, NewtonBody* const child, const dMatrix& parentPinAndPivotFrame, NewtonBody* const parent)
:CustomBallAndSocket(childPinAndPivotFrame, child, parent)
,m_rotationOffset(childPinAndPivotFrame * parentPinAndPivotFrame.Inverse())
{
SetConeAngle (0.0f);
SetTwistAngle (0.0f, 0.0f);
dMatrix matrix;
CalculateLocalMatrix (parentPinAndPivotFrame, matrix, m_localMatrix1);
}
开发者ID:alexsaen,项目名称:newton-dynamics,代码行数:9,代码来源:CustomBallAndSocket.cpp
示例18: GetBoundingBox
dBoundingBox PixelPrimitive::GetBoundingBox(const dMatrix &space)
{
dBoundingBox box;
for (vector<dVector,FLX_ALLOC(dVector) >::iterator i=m_Points.begin(); i!=m_Points.end(); ++i)
{
box.expand(space.transform(*i));
}
return box;
}
开发者ID:florolf,项目名称:fluxus-pp,代码行数:9,代码来源:PixelPrimitive.cpp
示例19:
dMatrix::dMatrix (const dMatrix & transformMatrix, const dVector & scale, const dMatrix & stretchAxis)
{
dMatrix scaledAxis;
scaledAxis[0] = stretchAxis[0].Scale (scale[0]);
scaledAxis[1] = stretchAxis[1].Scale (scale[1]);
scaledAxis[2] = stretchAxis[2].Scale (scale[2]);
scaledAxis[3] = stretchAxis[3];
*this = stretchAxis.Transpose() * scaledAxis * transformMatrix;
}
开发者ID:Hurleyworks,项目名称:NewtonBlock,代码行数:9,代码来源:dMatrix.cpp
示例20: GetBoundingBox
dBoundingBox NURBSPrimitive::GetBoundingBox(const dMatrix &space)
{
dBoundingBox box;
for (vector<dVector>::iterator i=m_CVVec->begin(); i!=m_CVVec->end(); ++i)
{
box.expand(space.transform(*i));
}
return box;
}
开发者ID:badgeek,项目名称:fluxus,代码行数:9,代码来源:NURBSPrimitive.cpp
注:本文中的dMatrix类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论