本文整理汇总了C++中e1函数的典型用法代码示例。如果您正苦于以下问题:C++ e1函数的具体用法?C++ e1怎么用?C++ e1使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了e1函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: p0
dgBigVector dgCollisionConvexHull::FaceNormal (const dgEdge *face, const dgBigVector* const pool) const
{
const dgEdge* edge = face;
dgBigVector p0 (pool[edge->m_incidentVertex]);
edge = edge->m_next;
dgBigVector p1 (pool[edge->m_incidentVertex]);
dgBigVector e1 (p1 - p0);
dgBigVector normal (dgFloat32 (0.0f));
for (edge = edge->m_next; edge != face; edge = edge->m_next) {
dgBigVector p2 (pool[edge->m_incidentVertex]);
dgBigVector e2 (p2 - p0);
dgBigVector n1 (e1.CrossProduct(e2));
#ifdef _DEBUG
dgAssert(n1.m_w == dgFloat32(0.0f));
dgFloat64 mag = normal.DotProduct(n1).GetScalar();
dgAssert ( mag >= -dgFloat32 (0.1f));
#endif
normal += n1;
e1 = e2;
}
dgFloat64 den = sqrt (normal.DotProduct(normal).GetScalar()) + dgFloat64 (1.0e-24f);
normal = normal.Scale (dgFloat64 (1.0f)/ den);
#ifdef _DEBUG
edge = face;
dgBigVector e0 (pool[edge->m_incidentVertex] - pool[edge->m_prev->m_incidentVertex]);
do {
dgBigVector de1 (pool[edge->m_next->m_incidentVertex] - pool[edge->m_incidentVertex]);
dgBigVector dn1 (e0.CrossProduct(de1));
dgFloat64 x = normal.DotProduct(dn1).GetScalar();
dgAssert (x > -dgFloat64 (0.01f));
e0 = de1;
edge = edge->m_next;
} while (edge != face);
#endif
return normal;
}
示例2: e0
void dgCollisionDeformableMesh::UpdateVisualNormals()
{
for (dgInt32 i = 0; i < m_trianglesCount; i ++) {
dgInt32 i0 = m_indexList[i * 3];
dgInt32 i1 = m_indexList[i * 3 + 1];
dgInt32 i2 = m_indexList[i * 3 + 2];
dgVector e0 (m_particles.m_posit[i1] - m_particles.m_posit[i0]);
dgVector e1 (m_particles.m_posit[i2] - m_particles.m_posit[i0]);
dgVector n = e0 * e1;
n = n.Scale3(dgRsqrt (n % n));
m_faceNormals[i] = n;
}
dgAssert (m_visualVertexData);
for (dgInt32 i = 0; i < m_visualVertexCount; i ++) {
m_visualVertexData[i].m_normals[0] = dgFloat32 (0.0f);
m_visualVertexData[i].m_normals[1] = dgFloat32 (0.0f);
m_visualVertexData[i].m_normals[2] = dgFloat32 (0.0f);
}
for (dgList<dgMeshSegment>::dgListNode* node = m_visualSegments.GetFirst(); node; node = node->GetNext() ) {
const dgMeshSegment& segment = node->GetInfo();
for (dgInt32 i = 0; i < segment.m_indexCount; i ++) {
dgInt32 index = segment.m_indexList[i];
dgInt32 faceIndexNormal = i / 3;
m_visualVertexData[index].m_normals[0] += m_faceNormals[faceIndexNormal].m_x;
m_visualVertexData[index].m_normals[1] += m_faceNormals[faceIndexNormal].m_y;
m_visualVertexData[index].m_normals[2] += m_faceNormals[faceIndexNormal].m_z;
}
}
for (dgInt32 i = 0; i < m_visualVertexCount; i ++) {
dgVector n (m_visualVertexData[i].m_normals[0], m_visualVertexData[i].m_normals[1], m_visualVertexData[i].m_normals[2], dgFloat32 (0.0f));
n = n.Scale3(dgRsqrt (n % n));
m_visualVertexData[i].m_normals[0] = n.m_x;
m_visualVertexData[i].m_normals[1] = n.m_y;
m_visualVertexData[i].m_normals[2] = n.m_z;
}
}
示例3: e5
static integer e5(void)
{
integer result;
char* name;
{
if (scan_test(NULL, SCAN_P_ID, NULL))
{
scan_test(NULL, SCAN_P_ID, &e5_stop);
name = SCAN_CAST->id;
scan_();
if (symbol_lookup_key(mini, &name, NULL) == NULL)\
{\
text_message(TEXT_ERROR, "Undeclared variable '%s'\n", name);\
symbol_insert_key(mini, &name, sizeof(char*), sizeof(mini_data));\
}\
result = mini_cast(symbol_lookup_key(mini, &name, NULL))->i;
}
else
if (scan_test(NULL, SCAN_P_INTEGER, NULL))
{
scan_test(NULL, SCAN_P_INTEGER, &e5_stop);
result = SCAN_CAST->data.i;
scan_();
}
else
if (scan_test(NULL, RDP_T_40 /* ( */, NULL))
{
scan_test(NULL, RDP_T_40 /* ( */, &e5_stop);
scan_();
result = e1();
scan_test(NULL, RDP_T_41 /* ) */, &e5_stop);
scan_();
}
else
scan_test_set(NULL, &e5_first, &e5_stop) ;
scan_test_set(NULL, &e5_stop, &e5_stop);
}
return result;
}
示例4: assert
void VertexNormalAttribute::compute_vertex_normals_from_edge(Mesh& mesh) {
const size_t dim = mesh.get_dim();
assert(dim == 2);
const size_t num_vertices = mesh.get_num_vertices();
const size_t num_faces = mesh.get_num_faces();
const size_t vertex_per_face = mesh.get_vertex_per_face();
const VectorF& normals = get_attribute(mesh, "face_normal");
VectorF& v_normals = m_values;
v_normals = VectorF::Zero(dim * num_vertices);
for (size_t i=0; i<num_faces; i++) {
VectorI face = mesh.get_face(i);
for (size_t j=0; j<vertex_per_face; j++) {
size_t prev = (j-1+vertex_per_face) % vertex_per_face;
size_t next = (j+1) % vertex_per_face;
Vector2F prev_edge = mesh.get_vertex(face[j]) -
mesh.get_vertex(face[prev]);
Vector2F next_edge = mesh.get_vertex(face[next]) -
mesh.get_vertex(face[j]);
Vector3F n = normals.segment(i*3, 3);
Vector3F e1(prev_edge[0], prev_edge[1], 0);
Vector3F e2(next_edge[0], next_edge[1], 0);
Vector3F n1 = e1.cross(n);
Vector3F n2 = e2.cross(n);
v_normals.segment(face[j]*dim, dim) += (n1 + n2).segment(0, dim);
}
}
for (size_t i=0; i<num_vertices; i++) {
Float norm = v_normals.segment(i*dim, dim).norm();
if (norm > 1e-6) {
v_normals.segment(i*dim, dim) /= norm;
}
}
}
示例5: e1
std::vector<ShapeState::Point> ShapeState::assignLTC(const std::vector<ShapeState::Point>& _points, float ltcr)
{
std::random_device rd;
std::default_random_engine e1(rd());
std::uniform_real_distribution<float> ltcrRnd(0, 1);
std::vector<Point> points = _points;
for (auto& p: points)
{
if (ltcrRnd(e1) >= ltcr)
{
p.t = 0.f;
}
else
{
p.t = m_curviness;
}
}
return points;
}
示例6: test_feature
bool test_feature()
{
int edata[_rank];
for (int i = 0; i < _rank; i++)
edata[i] = i+1;
extent<_rank> e1(edata);
_type *data = NULL;
data = new _type[e1.size()];
for (unsigned int i = 0; i < e1.size(); i++)
data[i] = (_type)rand();
{
bool pass = test_feature_itr<_type, _rank>(e1, data, data+e1.size()) &&
test_feature_itr<_type, _rank>(e1, data);
if (!pass)
return false;
}
return true;
}
示例7: main
int main(int argc, char * argv[]) {
std::array<double, 16>
t1 = {{ 1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1, }},
t2 = {{ 1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1, }};
// IN
Eigen::Map<Eigen::Matrix<double, 4, 4, Eigen::RowMajor>> e1((double*)t1.data());
Eigen::Quaternionf q1 = Eigen::Quaternionf( e1.topLeftCorner<3,3>().cast<float>() );
Eigen::Vector4f v1 = Eigen::Vector4f( e1.topRightCorner<4,1>().cast<float>() );
// OUT
Eigen::Map<Eigen::Matrix<double, 4, 4, Eigen::RowMajor>> e2((double*)t2.data());
e2.topLeftCorner<3,3>() = q1.toRotationMatrix().cast<double>();
e2.topRightCorner<4,1>() = v1.cast<double>();
// DISP
std::cout<<e1<<std::endl;
std::cout<<e2<<std::endl;
return 0;
}
示例8: H2
Z H2(e2){
I z;
I isWritableFile();
CX cx=Cx;
ND2;
z=*a->p;
if (It==a->t||qz(a))
{
if(dbg_txeq)xeqtrc((C *)w->p,3);
if(w->c||isWritableFile((I)w))z=pexm((I)w->p,APL);
else
{
C *buf=(C *)mab(w->n+1);
memmove(buf,w->p,w->n+1);
z=pexm((I)buf,APL);
mf((I *)buf);
}
if(dbg_txeq)xeqtrc((C *)w->p,2);
R z;
}
else R QS(z)?(Cx=cxi(XS(z)),z=e1(w),Cx=cx,z):(q=6,0);
}
示例9: origSrc
Msg* OneToAllMsg::copy( Id origSrc, Id newSrc, Id newTgt,
FuncId fid, unsigned int b, unsigned int n ) const
{
const Element* orig = origSrc();
if ( n <= 1 ) {
OneToAllMsg* ret = 0;
if ( orig == e1() ) {
ret = new OneToAllMsg( Msg::nextMsgId(), Eref( newSrc(), i1_ ), newTgt() );
ret->e1()->addMsgAndFunc( ret->mid(), fid, b );
} else if ( orig == e2() ) {
ret = new OneToAllMsg( Msg::nextMsgId(), Eref( newTgt(), i1_ ), newSrc() );
ret->e2()->addMsgAndFunc( ret->mid(), fid, b );
} else {
assert( 0 );
}
return ret;
} else {
// Here we need a SliceMsg which goes from one 2-d array to another.
cout << "Error: OneToAllMsg::copy: SliceToSliceMsg not yet implemented\n";
return 0;
}
}
示例10: nodeFromId
Node FlowGraph::_demandKariz(Demand d, Edge& srcEdge, Edge& trgEdge, Identifier demandId) {
// We find the kariz belong to demandId using three characteristics
// 1- A Kariz is only connected to its demand source and target
// 2- IsKariz is true for this node
// 3- A Kariz has the same id as the demand d.
Node src = nodeFromId(d.source());
Node trg = nodeFromId(d.target());
Node kariz = INVALID;
for (OutArcIt e1(*this, src); e1 != INVALID; ++e1) {
for (OutArcIt e2(*this, trg); e2 != INVALID; ++e2) {
Node tmp = this->target(e1);
if (tmp == this->target(e2) && isKariz_[tmp] && demandId_[tmp] == demandId) {
kariz = tmp;
srcEdge = e1; trgEdge = e2;
break;
}//if
}//if
}//for
return kariz;
}
示例11: sn
void Foam::myHeatFluxFvPatchVectorField::updateCoeffs()
{
if (this->updated())
{
return;
}
// VARIABLEN/FELDER
scalarField sn(patch().size()),
st(patch().size()),
sct(patch().size()),
gt(patch().size());
vectorField t(patch().size()),
n(patch().size());
vectorField& s = *this;
// Berechnung von Richtungen
n = this->patch().nf();
t = g0/mag(g0);
// Betrag in normalen Richtung n
fvPatchField<scalar> boundaryTheta = interpolateBoundaryTheta();
sn = alpha * (boundaryTheta - Theta_wall);
// Betrag in tangentiale Richtung t (Approximation durch einseitige FD)
vector e1(1,0,0);
vector e2(0,1,0);
vector e3(0,0,1);
vectorField sc = this->patchInternalField();
scalarField d = 1.0/this->patch().deltaCoeffs();
gt = ( (g0 ^ n) & e2 );
sct = ( (sc ^ n) & e2 );
st = ( sct - d*gt ) / ( 1 + d*gamma );
// gesamter Wärmestrom s
s = sn*n + st*t;
fixedValueFvPatchVectorField::updateCoeffs();
}
示例12: TEST_F
TEST_F(FunctionTests, TestThatLikeFunctionsAgree)
{
FunctionPtr u_prev = Teuchos::rcp( new UPrev );
vector<double> e1(2); // (1,0)
e1[0] = 1;
vector<double> e2(2); // (0,1)
e2[1] = 1;
FunctionPtr beta = e1 * u_prev + Teuchos::rcp( new ConstantVectorFunction( e2 ) );
FunctionPtr u_prev_squared_div2 = 0.5 * u_prev * u_prev;
checkFunctionsAgree(e2 * u_prev,
Teuchos::rcp( new ConstantVectorFunction( e2 ) ) * u_prev,
_basisCache);
FunctionPtr e1_f = Teuchos::rcp( new ConstantVectorFunction( e1 ) );
FunctionPtr e2_f = Teuchos::rcp( new ConstantVectorFunction( e2 ) );
FunctionPtr one = Teuchos::rcp( new ConstantScalarFunction( 1.0 ) );
checkFunctionsAgree( Teuchos::rcp( new ProductFunction(e1_f, (e1_f + e2_f)) ), // e1_f * (e1_f + e2_f)
one,
_basisCache);
vector<double> e1_div2 = e1;
e1_div2[0] /= 2.0;
checkFunctionsAgree(u_prev_squared_div2,
(e1_div2 * beta) * u_prev,
_basisCache);
checkFunctionsAgree(e1 * u_prev_squared_div2,
(e1_div2 * beta * e1) * u_prev,
_basisCache);
checkFunctionsAgree(e1 * u_prev_squared_div2 + e2 * u_prev,
(e1_div2 * beta * e1 + Teuchos::rcp( new ConstantVectorFunction( e2 ) )) * u_prev,
_basisCache);
}
示例13: test_timed_sharable_mutex
void test_timed_sharable_mutex()
{
SM mtx;
data<SM> s1(1,1*BaseSeconds);
data<SM> s2(2,3*BaseSeconds);
data<SM> e1(3,3*BaseSeconds);
data<SM> e2(4,1*BaseSeconds);
// We begin with some specialized tests for "timed" behavior
shared_val = 0;
// Writer one will hold the lock for 3*BaseSeconds seconds.
boost::thread tw1(thread_adapter<SM>(timed_exclusive,&e1,mtx));
boost::thread::sleep(xsecs(1*BaseSeconds));
// Writer two will "clearly" try for the lock after the readers
// have tried for it. Writer will wait up 1*BaseSeconds seconds for the lock.
// This write will fail.
boost::thread tw2(thread_adapter<SM>(timed_exclusive,&e2,mtx));
// Readers one and two will "clearly" try for the lock after writer
// one already holds it. 1st reader will wait 1*BaseSeconds seconds, and will fail
// to get the lock. 2nd reader will wait 3*BaseSeconds seconds, and will get
// the lock.
boost::thread thr1(thread_adapter<SM>(timed_shared,&s1,mtx));
boost::thread thr2(thread_adapter<SM>(timed_shared,&s2,mtx));
tw1.join();
thr1.join();
thr2.join();
tw2.join();
BOOST_INTERPROCES_CHECK(e1.m_value == 10);
BOOST_INTERPROCES_CHECK(s1.m_value == -1);
BOOST_INTERPROCES_CHECK(s2.m_value == 10);
BOOST_INTERPROCES_CHECK(e2.m_value == -1);
}
示例14: perp
void Cone::draw(bool debug) {
Point c = apex.translate(axis);
Vector e0 = perp(axis);
Vector v3 = e0.cross(axis);
Point e1(v3.getX(), v3.getY(), v3.getZ());
std::vector <Point> pts;
for (int i = 0; i < meridians; ++i) {
double rad = 2 * M_PI * i / meridians;
double x = c.getX() + (e0.getX() * cos(rad) + e1.getX() * sin(rad)) * rayon;
double y = c.getY() + (e0.getY() * cos(rad) + e1.getY() * sin(rad)) * rayon;
double z = c.getZ() + (e0.getZ() * cos(rad) + e1.getZ() * sin(rad)) * rayon;
Point p(x, y, z);
pts.push_back(p);
}
// draw cone top
glBegin(GL_TRIANGLE_FAN);
glPoint(apex);
for (int i = 0; i < meridians; ++i) {
glPoint(pts.at(i));
}
glPoint(pts.at(0));
glEnd();
if (debug) {
glColor3f(1.0f, 0.0f, 0.0f);
for (int i = 0; i < meridians; ++i) {
glBegin(GL_LINES);
glPoint(apex);
glPoint(pts.at(i));
glEnd();
}
}
}
示例15: TEST
TEST(HashedSetAbstractDomainTest, latticeOperations) {
Domain e1("a");
Domain e2({"a", "b", "c"});
Domain e3({"b", "c", "d"});
EXPECT_THAT(e1.elements(), ::testing::UnorderedElementsAre("a"));
EXPECT_THAT(e2.elements(), ::testing::UnorderedElementsAre("a", "b", "c"));
EXPECT_THAT(e3.elements(), ::testing::UnorderedElementsAre("b", "c", "d"));
std::ostringstream out;
out << e1;
EXPECT_EQ("[#1]{a}", out.str());
EXPECT_TRUE(e1.leq(e2));
EXPECT_FALSE(e1.leq(e3));
EXPECT_TRUE(e2.equals(Domain({"b", "c", "a"})));
EXPECT_FALSE(e2.equals(e3));
EXPECT_THAT(e2.join(e3).elements(),
::testing::UnorderedElementsAre("a", "b", "c", "d"));
EXPECT_TRUE(e1.join(e2).equals(e2));
EXPECT_TRUE(e1.widening(e2).equals(e2));
EXPECT_THAT(e2.meet(e3).elements(),
::testing::UnorderedElementsAre("b", "c"));
EXPECT_TRUE(e1.meet(e2).equals(e1));
EXPECT_FALSE(e1.meet(e3).is_bottom());
EXPECT_TRUE(e1.meet(e3).elements().empty());
EXPECT_TRUE(e1.narrowing(e2).equals(e1));
EXPECT_TRUE(e2.contains("a"));
EXPECT_FALSE(e3.contains("a"));
// Making sure no side effect happened.
EXPECT_THAT(e1.elements(), ::testing::UnorderedElementsAre("a"));
EXPECT_THAT(e2.elements(), ::testing::UnorderedElementsAre("a", "b", "c"));
EXPECT_THAT(e3.elements(), ::testing::UnorderedElementsAre("b", "c", "d"));
}