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


C++ Wvec::normalized方法代码示例

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


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

示例1:

//! 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

示例2: 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

示例3: pow

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

示例4: setup

//! Given an initial slash gesture (or delayed slash) near the
//! center of an existing straight Bcurve, set up the widget to
//! do a sweep cross-ways to the Bcurve:
bool
SWEEP_LINE::setup(CGESTUREptr& slash, double dur)
{

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

   err_adv(debug, "SWEEP_LINE::setup");

   // check the gesture
   if (!(slash && slash->straightness() > 0.99)) {
      err_adv(debug, "SWEEP_LINE::setup: gesture is bad");
      return false;
   }

   // find the (straight) Bcurve near slash start
   _curve = Bcurve::hit_ctrl_curve(slash->start());
   if (!(_curve && _curve->is_straight())) {
      err_adv(debug, "SWEEP_LINE::setup: no straight curve at start");
      return false;
   }

   // find endpoints
   Bpoint *b1 = _curve->b1(), *b2 = _curve->b2();
   assert(b1 && b2);    // straight curve must have endpoints

   // curve cannot be connected to other curves
   if (b1->vert()->degree() != 1 || b2->vert()->degree() != 1) {
      err_adv(debug, "SWEEP_LINE::setup: curve is not isolated");
      return false;
   }

   // ensure the gesture starts near the center of the straight line Bcurve:
   {
      PIXEL a = b1->vert()->pix();
      PIXEL b = b2->vert()->pix();
      double t = (slash->start() - a).tlen(b-a);
      if (t < 0.35 || t > 0.65) {
         err_adv(debug, "SWEEP_LINE::setup: gesture not near center of line");
         return false;
      }
   }

   // find the plane to work in
   _plane = check_plane(shared_plane(b1, b2));
   if (!_plane.is_valid()) {
      err_adv(debug, "SWEEP_LINE::setup: no valid plane");
      return false;
   }

   // check that slash is perpendicular to line
   Wpt  a = b1->loc();  // endpoint at b1
   Wpt  b = b2->loc();  // endpoint at b2
   Wvec t = b - a;      // vector from endpt a to endpt b
   Wpt  o = a + t/2;    // center of straight line curve
   Wvec n = cross(_plane.normal(), t); // direction across line ab

   Wvec slash_vec = endpt_vec(slash, _plane);
   const double ALIGN_ANGLE_THRESH = 15;
   double angle = rad2deg(slash_vec.angle(n));
   if (angle > 90) {
      angle = 180 - angle;
      n = -n;
   }
   if (angle > ALIGN_ANGLE_THRESH) {
      err_adv(debug, "SWEEP_LINE::setup: slash is not perpendicular to line");
      err_adv(debug, "                   angle: %f", angle);
      return false;
   }

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

   return SWEEP_BASE::setup(_curve->mesh(), o, endpt, dur);
}
开发者ID:QuLogic,项目名称:jot-lib,代码行数:78,代码来源:sweep.cpp

示例5: set_norm

 // Assign a normal explicitly. Note that if vertices are moved,
 // nearby normals will be recomputed by averaging face normals.
 // XXX - does not apply to vertices on creases
 void set_norm(Wvec n) {
    _norm = n.normalized();
    set_bit(VALID_NORMAL_BIT); 
 }
开发者ID:QuLogic,项目名称:jot-lib,代码行数:7,代码来源:bvert.hpp


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