当前位置: 首页>>代码示例>>C++>>正文


C++ Wvec类代码示例

本文整理汇总了C++中Wvec的典型用法代码示例。如果您正苦于以下问题:C++ Wvec类的具体用法?C++ Wvec怎么用?C++ Wvec使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Wvec类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: kernel_vec

inline Wvec
kernel_vec(const WMat3& M)
{
   // return a vector perpendicular to all 3 rows

   // only supposed to call this on a singular matrix
   if (fabs(M.det()) > 1e-5) {
      cerr << "kernel_vec: warning: matrix is not singular:"
           << endl
           << M
           << endl
           << "determinant: "
           << M.det()
           << endl;
      return Wvec();
   }

   // get row vectors, changed to unit length or null:
   Wvec r0 = M.row(0).normalized();
   Wvec r1 = M.row(1).normalized();
   Wvec r2 = M.row(2).normalized();

   // re-order to push null ones to the end:
   if (r0.is_null()) swap(r0,r1);
   if (r0.is_null()) swap(r0,r2);
   if (r1.is_null()) swap(r1,r2);

   Wvec ret = cross(r0,r1).normalized();
   if (ret.is_null())
      ret = cross(r0,r2).normalized();
   if (ret.is_null())
      ret = Wvec::X();
   assert(isZero(ret*r0) && isZero(ret*r1) && isZero(ret*r2));
   return ret;
}
开发者ID:ArnaudGastinel,项目名称:jot-lib,代码行数:35,代码来源:align.C

示例2: err_adv

//! Given a set of enclosed face, activate the widget to sweep out a
//! shape. Checks for errors, returns true on success.
bool
SWEEP_DISK::setup(CGESTUREptr& gest, double dur)
{

   static bool debug =
      Config::get_var_bool("DEBUG_SWEEP_SETUP",false) || debug_all;

   if (!(gest && gest->is_dslash())) {
      err_adv(debug, "SWEEP_DISK::setup: bad gesture");
      return false;
   }

   // XXX - shouldn't require it is a Panel:
   Panel* p = dynamic_cast<Panel*>(Bsurface::hit_ctrl_surface(gest->start()));
   if (!p) {
      err_adv(debug, "SWEEP_DISK::setup: non-panel");
      return false;
   }

   Bface_list faces = p->bfaces();

   _boundary = faces.get_boundary();
   if (_boundary.num_line_strips() != 1) {
      err_adv(debug, "SWEEP_DISK::setup: error: boundary is not a single piece");
      return false;
   }

   // Get the best-fit plane, rejecting if the boundary Wpt_list
   // doesn't lie within 0.1 of its total length from the plane:
   if (!_boundary.verts().pts().get_plane(_plane, 0.1)) {
      err_adv(debug,"SWEEP_DISK::setup: Error: can't find plane");
      return false;
   }
   
   // Find the center
   Wpt o = _boundary.verts().pts().average();

   // decide guideline direction (normal to plane):
   Wvec n = _plane.normal();
   if (VIEW::eye_vec(o) * n > 0)
      n = -n;

   // decide the length for the guideline:
   double len = world_length(o, GUIDE_LEN);

   // compute guideline endpoint:
   Wpt b = o + n.normalized()*len;

   // try basic setup
   if (!SWEEP_BASE::setup(dynamic_pointer_cast<LMESH>(faces.mesh()), o, b, dur))
      return false;

   // ******** From here on we accept it ********

   _enclosed_faces = faces;

   return true;
}
开发者ID:QuLogic,项目名称:jot-lib,代码行数:60,代码来源:sweep.cpp

示例3: at

Wvec
Bface_list::avg_normal() const
{
   // Returns the average of the face normals
   Wvec ret;
   for (Bface_list::size_type i=0; i<size(); i++)
      ret += at(i)->norm();
   return ret.normalized();
}
开发者ID:QuLogic,项目名称:jot-lib,代码行数:9,代码来源:bface.cpp

示例4: get_quad_pts

Wvec
Bface::quad_tan2() const 
{
   // Based on the 4 verts in standard orientation as above,
   // return the tangent vector running up
   Wpt a, b, c, d;
   get_quad_pts(a,b,c,d);

   Wvec t = ((d - a) + (c - b))*0.5;
   return t.orthogonalized(quad_norm()).normalized();
}
开发者ID:QuLogic,项目名称:jot-lib,代码行数:11,代码来源:bface.cpp

示例5: assert

void
XToonStripCB::faceCB(CBvert* v, CBface* f)
{
   assert(v && f);
   Wvec bNorm; //Blended Normal

   //first calculate the abstract(blended) normal
   switch(_blend_type) {
    case XToonStripCB::SMOOTH: {
       // Note: doesn't work
       bNorm = v->get_all_faces().n_ring_faces(3).avg_normal();
    }
      break;
    case XToonStripCB::SPHERIC: {
       BMESH* mesh = v->mesh();
       Wpt c = mesh->get_bb().center();
       bNorm = (v->loc()-c).normalized();
    }
      break;
    case XToonStripCB::ELLIPTIC: {
       BMESH* mesh = v->mesh();
       Wvec c_to_v = v->loc() - mesh->get_bb().center();
       Wvec dim = mesh->get_bb().dim();
       double a = dim[0]*0.5;
       double b = dim[1]*0.5;
       double c = dim[2]*0.5;
       bNorm = Wvec(c_to_v[0]/a, c_to_v[1]/b, c_to_v[2]/c).normalized();
    }
      break;
    case XToonStripCB::CYLINDRIC: {
       BMESH* mesh = v->mesh();
       Wpt c = mesh->get_bb().center();
       Wvec axis;
       Wvec dim = mesh->get_bb().dim();
       if (dim[0]>dim[1] && dim[0]>dim[2])
          axis = dim.X();
       else if (dim[1]>dim[0] && dim[1]>dim[2])
          axis = dim.Y();         
       else 
          axis = dim.Z();         
      
       Wpt v_proj = c + ((v->loc()-c)*axis) * axis;
       bNorm = (v->loc()-v_proj).normalized();
    }
      break;
    default:
      assert(0);
   }

   //set the blended normal, the regular normal and the vertex point
   glVertexAttrib3f(_loc, bNorm[0], bNorm[1], bNorm[2]); 
   glNormal3dv(f->vert_normal(v).data());
   glVertex3dv(v->loc().data());
}
开发者ID:ArnaudGastinel,项目名称:jot-lib,代码行数:54,代码来源:glsl_xtoon.C

示例6: snap

NDCpt 
Bface::nearest_pt_ndc(CNDCpt& p, Wvec &bc, int &is_on_tri) const 
{
   // Bsimplex virtual method

   // same as above, but operates in NDC space

   // get barycentric coords:
   NDCpt a = _v1->ndc();
   NDCpt b = _v2->ndc();
   NDCpt c = _v3->ndc();
   double A = signed_area_ndc(a, b, c);
   double u = signed_area_ndc(p, b, c) / A;
   double v = signed_area_ndc(a, p, c) / A;
   bc.set(u, v, 1 - u - v);
   
   // to account for numerical errors, snap
   // near-zero values to 0 and renormalize
   snap(bc);

   if (bc[0] < 0 || bc[1] < 0 || bc[2] < 0) {
      // p is outside the triangle.
      // find closest point to an edge:
      is_on_tri = 0;
      double t1, t2, t3;

      NDCpt p1 = pt_near_seg_ndc(a,b,p,t1);
      NDCpt p2 = pt_near_seg_ndc(b,c,p,t2);
      NDCpt p3 = pt_near_seg_ndc(c,a,p,t3);

      double d1 = p.dist_sqrd(p1);
      double d2 = p.dist_sqrd(p2);
      double d3 = p.dist_sqrd(p3);

      if (d1 < d2) {
         if (d1 < d3) {
            bc.set(1-t1,t1,0);
            return p1;
         }
         bc.set(t3,0,1-t3);
         return p3;
      }
      if (d2 < d3) {
         bc.set(0,1-t2,t2);
         return p2;
      }
      bc.set(t3,0,1-t3);
      return p3;
   }

   is_on_tri = 1;
   return (a*bc[0]) + (b*bc[1]) + (c*bc[2]);
}
开发者ID:QuLogic,项目名称:jot-lib,代码行数:53,代码来源:bface.cpp

示例7: sqrt

double
Collide::intersectSphere(CWpt& rO, CWvec& rV, CWpt& sO, double sR)
{
   Wvec Q = sO - rO;
   double c = Q.length();
   double v = Q * rV;
   double d = sR*sR - (c*c - v*v);

   // If there was no intersection, return -1

   if (d < 0.0) return -1.0;

   // Return the distance to the [first] intersecting point

   return v - sqrt(d);
}
开发者ID:ArnaudGastinel,项目名称:jot-lib,代码行数:16,代码来源:collide.C

示例8: norm

void 
Bpoint::remove_constraining_surface()
{
  if ( !(constraining_surface()) ){
    cerr << "Bpoint::remove_constraining_surface() "
         << "has no surface constraint" << endl;
    return;
  }

  // save the normal
  Wvec n = norm();

  // remove the shadow, if any 
  remove_shadow();
  set_map(new WptMap(loc()), false);

  if (!n.is_null())
    _map->set_norm(n);
}
开发者ID:ArnaudGastinel,项目名称:jot-lib,代码行数:19,代码来源:bpoint.C

示例9: if

Wpt
Bedge::nearest_pt(CWpt& p, Wvec &bc, bool &is_on_simplex) const
{
    Wvec ab = _v2->loc() - _v1->loc();
    Wvec ac = p - _v1->loc();

    double dot = (ab * ac) / ab.length_sqrd();
    bc.set(1-dot, dot, 0);

    if (dot < gEpsZeroMath) {
        bc.set(1, 0, 0);
        is_on_simplex = (dot >= 0);
    } else if (1-dot < gEpsZeroMath) {
        bc.set(0, 1, 0);
        is_on_simplex = (dot <= 1);
    }

    return (bc[0] * _v1->loc()) + (bc[1] * _v2->loc());
}
开发者ID:karmakat,项目名称:jot-lib,代码行数:19,代码来源:bedge.C

示例10: add_shading

inline void
add_shading(CBvert_list& verts, Wvec l, CCOLOR& col, double s = 1.0)
{
   // normalize the "light" vector:

   l = l.normalized();
   for (size_t i=0; i<verts.size(); i++) {
      double a = pow(max(l * verts[i]->norm(), 0.0), s);
      if (a > 0)
         verts[i]->set_color(interp(verts[i]->color(), col, a), 1);
   }
}
开发者ID:QuLogic,项目名称:jot-lib,代码行数:12,代码来源:color_mesh.cpp

示例11: cross

void
CIRCLE_WIDGET::make_preview( void )
{
   _preview.clear();

   // Get a coordinate system
   Wvec Z = _plane.normal();
   Wvec X = Z.perpend();
   Wvec Y = cross(Z,X);
   Wtransf xf(_center, X, Y, Z);

   // Make the hi-res circle for the curve's map1d3d:
   const int ORIG_RES = 256;
   _preview.realloc(ORIG_RES + 1);
   double dt = (2*M_PI)/ORIG_RES;
   for (int i=0; i<ORIG_RES; i++) {
      double t = dt*i;
      _preview += xf*Wpt(_radius*cos(t), _radius*sin(t), 0);
   }
   _preview += _preview[0];       // make it closed

   if( _suggest_active ) {
      return;
   }

   if( _circle == 0 ) {
      // XXX - no undo! should fix
      _circle = PanelAction::create(
         _plane, _center, _radius, TEXBODY::get_skel_mesh(0), _disk_res, 0
         );
   } else {
      Bcurve *border = Bcurve::lookup(_circle->bfaces().get_boundary().edges());
      if( border != 0 ) {
         Wpt_listMap *map = Wpt_listMap::upcast(border->map());
         if( map )
            map->set_pts(_preview);
      }
   }

}
开发者ID:Benignoperez,项目名称:jot-lib,代码行数:40,代码来源:circle_widget.C

示例12: if

/**********************************************************************
 * NPRSolidTexCB:
 **********************************************************************/
void 
NPRSolidTexCB::faceCB(CBvert* v, CBface*f) 
{
   Wvec n;
   f->vert_normal(v,n);

   if (!nst_use_vertex_program)
   {
      if (nst_tex_flag) {
         TexCoordGen* tg = f->patch()->tex_coord_gen();
         if (tg) 
            glTexCoord2dv(tg->uv_from_vert(v,f).data());
         else if (UVdata::lookup(f))
            glTexCoord2dv(UVdata::get_uv(v,f).data());
      }
   
      if (nst_paper_flag)
         PaperEffect::paper_coord(NDCZpt(v->wloc()).data());
      
      glNormal3dv(n.data());
      glVertex3dv(v->loc().data());
   }
   else
   {
      if (nst_tex_flag)
      {
         TexCoordGen* tg = f->patch()->tex_coord_gen();
         if (tg) 
            glTexCoord2dv(tg->uv_from_vert(v,f).data());
         else if (UVdata::lookup(f))
            glTexCoord2dv(UVdata::get_uv(v,f).data());
      }


      glNormal3dv(n.data());
      glVertex3dv(v->loc().data());
   }

}
开发者ID:QuLogic,项目名称:jot-lib,代码行数:42,代码来源:npr_solid_texture.cpp

示例13: skin_loc

CWpt& 
SkinMeme::compute_update()
{
   static bool debug = ::debug || Config::get_var_bool("DEBUG_SKIN_UPDATE",false);

   // compute 3D vertex location WRT track simplex

   if (_is_sticky) {
      // this meme is supposed to follow the skeleton surface
      if (is_tracking()) {
         // it actually is following it
         return _update = skin_loc(track_simplex(), _bc, _h);
      }
      // supposed to follow, but has no track point: do nothing
      return _update = loc();
   }

   // this meme is not following the skeleton surface;
   // it computes its location via smooth subdivision.
   // but it may still track the closest point on the skeleton
   // surface to avoid penetrating inside the skeleton surface.

   if (vert()->parent() == 0)
      _update = loc();
   else
      _update = vert()->detail_loc_from_parent();
   track_to_target(_update);
   if (_non_penetrate && is_tracking()) {
      Wvec d = penetration_correction(_update, track_simplex(), _bc, _stay_out);
      if (debug && !d.is_null())
         err_msg("SkinMeme::compute_update: correcting penetration, level %d",
                 bbase()->subdiv_level());
      _update += d;
               
   }
   return _update;
}
开发者ID:ArnaudGastinel,项目名称:jot-lib,代码行数:37,代码来源:skin_meme.C

示例14: assert

bool 
SWEEP_LINE::create_rect(CWvec& v)
{
   // create a rectangular Panel based on given vector along the guideline

   //   Get oriented as follows, looking down onto the plane:
   //                                                       
   //      b1 . . . . . . . b4                              
   //      |                 .                              
   //      |                 .                              
   //      |                 .                              
   //      | ------- v ----->.                              
   //      |                 .                              
   //      |                 .                              
   //      |                 .                              
   //      b2 . . . . . . . b3                              

   static bool debug =
      Config::get_var_bool("DEBUG_CREATE_RECT",false) || debug_all;

   assert(_curve != nullptr);
   Bpoint *b1 = _curve->b1(), *b2 = _curve->b2();
   assert(b1 && b2);
   Wvec u = b2->loc() - b1->loc();      // vector along existing straight line

   // Swap b1 and b2 if necessary:
   Wvec n = _plane.normal();
   if (det(v,n,u) < 0) {
	  err_adv(debug, "SWEEP_LINE::create_rect: b1 and b2 swapped");
      //swap(b1,b2);
      //u = -u;
   }

   // Decide number of edges "horizontally" (see diagram above)
   int num_v = _curve->num_edges(); // number of edges "vertically"
   double H = u.length();           // "height"
   double W = v.length();           // "width"
   double l = H/num_v;              // length of an edge "vertically"
   int num_h = (int)round(W/l);     // number of edges "horizontally"
   if (num_h < 1) {
      // Needs more work to handle this case. Bail for now:
      err_adv(debug, "SWEEP_LINE::create_rect: cross-stroke too short");
      return false;
   }

   // Accept it now

   LMESHptr m = _curve->mesh();
   Wpt p1 = b1->loc(), p2 = b2->loc(), p3 = p2 + v, p4 = p1 + v;

   MULTI_CMDptr cmd = make_shared<MULTI_CMD>();

   // Create points b3 and b4
   Bpoint* b3 = BpointAction::create(m, p3, n, v, b2->res_level(), cmd);
   Bpoint* b4 = BpointAction::create(m, p4, n, v, b1->res_level(), cmd);

   // Create the 3 curves: bottom, right and top
   Wpt_list side;
   int res_lev = _curve->res_level();

   err_adv(debug, "SWEEP_LINE::create_rect: curve res level: %d", res_lev);

   Bcurve_list contour;
   contour += _curve;

   // Bottom curve
   side.clear(); side.push_back(p2); side.push_back(p3);
   contour += BcurveAction::create(m, side, n, num_h, res_lev, b2, b3, cmd);

   // Right curve
   side.clear(); side.push_back(p3); side.push_back(p4);
   contour += BcurveAction::create(m, side, n, num_v, res_lev, b3, b4, cmd);

   // Top curve
   side.clear(); side.push_back(p4); side.push_back(p1);
   contour += BcurveAction::create(m, side, n, num_h, res_lev, b4, b1, cmd);

   // Interior
   PanelAction::create(contour, cmd);
   
   WORLD::add_command(cmd);
   
   return true;
}
开发者ID:QuLogic,项目名称:jot-lib,代码行数:84,代码来源:sweep.cpp

示例15: clamp_barycentric

 static void clamp_barycentric(Wvec &bc) {
    bc.set(max(bc[0],0.0), max(bc[1],0.0), max(bc[2],0.0));
    bc /= (bc[0] + bc[1] + bc[2]);
 }
开发者ID:QuLogic,项目名称:jot-lib,代码行数:4,代码来源:bsimplex.hpp


注:本文中的Wvec类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。