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


C++ perp函数代码示例

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


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

示例1: perp

int QDockWidgetLayout::titleHeight() const
{
    QDockWidget *q = qobject_cast<QDockWidget*>(parentWidget());

    if (QWidget *title = widget(TitleBar))
        return perp(verticalTitleBar, title->sizeHint());

    QSize closeSize(0, 0);
    QSize floatSize(0, 0);
    if (QLayoutItem *item = item_list[CloseButton])
        closeSize = item->widget()->sizeHint();
    if (QLayoutItem *item = item_list[FloatButton])
        floatSize = item->widget()->sizeHint();

    int buttonHeight = qMax(perp(verticalTitleBar, closeSize),
                            perp(verticalTitleBar, floatSize));

    QFontMetrics titleFontMetrics = q->fontMetrics();
#ifdef Q_WS_MAC
    if (qobject_cast<QMacStyle *>(q->style())) {
        extern QHash<QByteArray, QFont> *qt_app_fonts_hash(); // qapplication.cpp
        QFont font = qt_app_fonts_hash()->value("QToolButton", q->font());
        titleFontMetrics = QFontMetrics(font);
    }
#endif

    int mw = q->style()->pixelMetric(QStyle::PM_DockWidgetTitleMargin, 0, q);

    return qMax(buttonHeight + 2, titleFontMetrics.lineSpacing() + 2*mw);
}
开发者ID:muromec,项目名称:qtopia-ezx,代码行数:30,代码来源:qdockwidget.cpp

示例2: perp

int QDockWidgetLayout::titleHeight() const
{
    QDockWidget *q = qobject_cast<QDockWidget*>(parentWidget());

    if (QWidget *title = widgetForRole(TitleBar))
        return perp(verticalTitleBar, title->sizeHint());

    QSize closeSize(0, 0);
    QSize floatSize(0, 0);
    if (QLayoutItem *item = item_list[CloseButton])
        closeSize = item->widget()->sizeHint();
    if (QLayoutItem *item = item_list[FloatButton])
        floatSize = item->widget()->sizeHint();

    int buttonHeight = qMax(perp(verticalTitleBar, closeSize),
                            perp(verticalTitleBar, floatSize));

    QFontMetrics titleFontMetrics = q->fontMetrics();
#ifdef Q_WS_MAC
    if (qobject_cast<QMacStyle *>(q->style())) {
        //### this breaks on proxy styles.  (But is this code still called?)
        QFont font = qt_app_fonts_hash()->value("QToolButton", q->font());
        titleFontMetrics = QFontMetrics(font);
    }
#endif

    int mw = q->style()->pixelMetric(QStyle::PM_DockWidgetTitleMargin, 0, q);

    return qMax(buttonHeight + 2, titleFontMetrics.height() + 2*mw);
}
开发者ID:phen89,项目名称:rtqt,代码行数:30,代码来源:qdockwidget.cpp

示例3: addPolygonPolylinePoint

void addPolygonPolylinePoint(Line& line,
    const glm::vec3 curr,
    const glm::vec3 next,
    const glm::vec3 last,
    const float extrude,
    size_t lineDataSize,
    size_t i,
    bool forward)
{
    glm::vec3 n0 = perp(curr - last);
    glm::vec3 n1 = perp(next - curr);
    bool right = glm::cross(n1, n0).z > 0.0;

    if ((i == 1 && forward) || (i == lineDataSize - 2 && !forward)) {
        line.push_back(last + n0 * extrude);
        line.push_back(last - n0 * extrude);
    }

    if (right) {
        glm::vec3 d0 = glm::normalize(last - curr);
        glm::vec3 d1 = glm::normalize(next - curr);
        glm::vec3 miter = computeMiterVector(d0, d1, n0, n1);
        line.push_back(curr - miter * extrude);
    } else {
        line.push_back(curr - n0 * extrude);
        line.push_back(curr - n1 * extrude);
    }
}
开发者ID:karimnaaji,项目名称:vectiler,代码行数:28,代码来源:vectiler.cpp

示例4: Intersect

bool Intersect(float2 &point, const Line &line0, const Line &line1)
{
#if 0
	float d = perp(line0.d, line1.d);
	if (d > -0.000000000001f) // Parallel lines
		return false;

	float2 diff = line0.v - line1.v;

	float t = perp(line1.d, diff);

	if (t > 0.0f) // Intersects on the wrong side
		return false;

	point = line0.v + (t / d) * line0.d;
	return true;
#else
	float d = perp(line0.d, line1.d);
	if (fabsf(d) < 0.000000000001f) // Parallel lines
		return false;

	float t = perp(line1.d, line0.v - line1.v) / d;

	if (t < 0.5f) // Intersects on the wrong side
		return false;

	point = line0.v + t * line0.d;
	return true;

#endif
}
开发者ID:DanielNeander,项目名称:my-3d-engine,代码行数:31,代码来源:ConvexHull.cpp

示例5: switch

	DebugDraw::DebugDraw(const Collider &coll)
	{

		isRigidBody = false;

		switch (coll.shape)
		{
			case Collider::e_AABB:
			{
				Vertex vertices[] = { Vertex(coll.aabb.max, SHAPECOLOR),
									  Vertex(Vector2{ coll.aabb.min.x, coll.aabb.max.y }, SHAPECOLOR),
									  Vertex(coll.aabb.min, SHAPECOLOR),
									  Vertex(Vector2{ coll.aabb.max.x, coll.aabb.min.y }, SHAPECOLOR) };
				mesh = new Mesh(vertices, 4);
				break;
			}
			case Collider::e_CIRCLE:
			{
				int step = 36;
				
				std::vector<Vertex> vertices;

				float anglePerStep = DEG2RAD(360.0f / step);

				for (unsigned i = 0; i < step; ++i)
					vertices.push_back(Vertex{ Vector2{coll.circle.position.x + cosf(i * anglePerStep) * coll.circle.radius,
													   coll.circle.position.y + sinf(i * anglePerStep) * coll.circle.radius},Vector4{(float)i / step, ((float)i+3) / step * 2, ((float)i + 8) / step * 3 , 1 } });

				mesh = new Mesh(&vertices[0], step);
				break;
			}
			case Collider::e_RAY:
			{
				Vertex vertices[] = { Vertex(coll.ray.position, SHAPECOLOR),
									  Vertex(coll.ray.position +
											(coll.ray.direction *
											 coll.ray.length) , SHAPECOLOR) };
				mesh = new Mesh(vertices, 2);
				break;
			}
			case Collider::e_PLANE:
			{
				Vertex vertices[] = { Vertex(coll.plane.position + (perp(coll.plane.normal) * 30), SHAPECOLOR),
									  Vertex(coll.plane.position - (perp(coll.plane.normal) * 30), SHAPECOLOR) };
				mesh = new Mesh(vertices, 2);
				break;
			}
			case Collider::e_CONVEX:
			{
				std::vector<Vertex> vertices;
			
				for (unsigned i = 0; i < coll.chull.size; ++i)
					vertices.push_back(Vertex{ coll.chull.verts[i], SHAPECOLOR });

				mesh = new Mesh(&vertices[0], coll.chull.size);
				break;
			}
		}
	}
开发者ID:Sethix,项目名称:GameEngine,代码行数:59,代码来源:DebugDraw.cpp

示例6: Vector

Point Line::intersect(const Line& o, float& t, float& s) const{
  Vector u = d;
  Vector v = o.d;
  Vector w = Vector(p - o.p);
  Vector vp = perp(v);
  Vector up = perp(u);
  t = -vp.dot(w) / vp.dot(u);
  s = up.dot(w) / up.dot(v);
  return eval(t);
}
开发者ID:gt-ros-pkg,项目名称:hrl,代码行数:10,代码来源:Line.cpp

示例7: IntersectNoParallelCheck

bool IntersectNoParallelCheck(float2 &point, const Line &line0, const Line &line1)
{
	float d = perp(line0.d, line1.d);
	float t = perp(line1.d, line0.v - line1.v) / d;

	if (t < 0.5f) // Intersects on the wrong side
		return false;

	point = line0.v + t * line0.d;
	return true;
}
开发者ID:DanielNeander,项目名称:my-3d-engine,代码行数:11,代码来源:ConvexHull.cpp

示例8: sat

/* Separate Axis Theorem test - project both polygon's
   vertices onto all axes defined by edges the polygons
   and if there is a gap between the polygons in any
   projection then they do not overlap */
static int sat(polygon_t a, polygon_t b) {
    int i;
    for (i = 0; i < a.n; i++) {
        vector_t axis = perp(direction(vertex(a, i), vertex(a, i + 1)));
        range_t ap = project(a, axis), bp = project(b, axis);
        if (!overlap(ap, bp)) return 0;
    }
    for (i = 0; i < b.n; i++) {
        vector_t axis = perp(direction(vertex(b, i), vertex(b, i + 1)));
        range_t ap = project(a, axis), bp = project(b, axis);
        if (!overlap(ap, bp)) return 0;
    }
    return 1;
}
开发者ID:StudyNAYO,项目名称:fastshp,代码行数:18,代码来源:sat.c

示例9: iTest_data

CollisionData iTest_data(const Ray2D &ac, const Plane2D &bc)
{
    CollisionData cd = { 0 };
    float r = mag(bc.normal * (ac.position - bc.position) / -(bc.normal * ac.direction));
    if (r <= 0 && r <= ac.length) cd = { r, perp(bc.normal) };
    return cd;
}
开发者ID:Sethix,项目名称:GameEngine,代码行数:7,代码来源:Ray2D.cpp

示例10: while

// return true if the polygon is couterclockwise ordered
bool glc::isCounterclockwiseOrdered(const QList<GLC_Point2d>& polygon)
{
	const int size= polygon.size();
	int j0= 0;
	int j1= size - 1;
	// test segment <polygon[i0], polygon[i1]> to see if it is a diagonal
	while (j0 < size)
	{
		GLC_Vector2d perp((polygon[j0] - polygon[j1]).perp());
		int j2= 0;
		int j3= size - 1;
		bool isIntersect= false;
		// Application of perp vector
		GLC_Point2d moy((polygon[j0] + polygon[j1]) * 0.5);
		while (j2 < size && !isIntersect)
		{
			if(j2 != j0 && j3 != j1)
			{
				if (isIntersectedRaySegment(moy, (perp + moy), polygon[j2], polygon[j3]))
					isIntersect= true;
			}
			j3= j2;
			++j2;
		}
		if(!isIntersect) return false;
		j1= j0;
		++j0;
	}

	return true;

}
开发者ID:AlessioMorale,项目名称:GLC_lib,代码行数:33,代码来源:glc_geomtools.cpp

示例11: draw_arrow2d

void draw_arrow2d(const Vec2f& start, const Vec2f& end, float arrow_head_len)
{
   Vec2f direction = end - start;

   Vec2f dir_norm = direction;

   //TODO Possibly automatically scale arrowhead length based on vector magnitude
   if(dir_norm.norm() < 1e-14)
      return;

   dir_norm.normalize();
   Vec2f perp(dir_norm[1],-dir_norm[0]);

   Vec2f tip_left = end + arrow_head_len/(float)sqrt(2.0)*(-dir_norm + perp);
   Vec2f tip_right = end + arrow_head_len/(float)sqrt(2.0)*(-dir_norm - perp);

   glBegin(GL_LINES);
   glVertex2f(start[0], start[1]);
   glVertex2f(end[0], end[1]);
   glVertex2f(end[0], end[1]);
   glVertex2f(tip_left[0], tip_left[1]);
   glVertex2f(end[0], end[1]);
   glVertex2f(tip_right[0], tip_right[1]);
   glEnd();

}
开发者ID:mtao,项目名称:Fluid,代码行数:26,代码来源:glwidget.cpp

示例12: dir

void CCSBot::Panic(CBasePlayer *pEnemy)
{
	if (IsSurprised())
		return;

	Vector2D dir(BotCOS(pev->v_angle.y), BotSIN(pev->v_angle.y));
	Vector2D perp(-dir.y, dir.x);
	Vector spot;

	if (GetProfile()->GetSkill() >= 0.5f)
	{
		Vector2D toEnemy = (pEnemy->pev->origin - pev->origin).Make2D();
		toEnemy.NormalizeInPlace();

		float along = DotProduct(toEnemy, dir);

		float c45 = 0.7071f;
		float size = 100.0f;

		real_t shift = RANDOM_FLOAT(-75.0, 75.0);

		if (along > c45)
		{
			spot.x = pev->origin.x + dir.x * size + perp.x * shift;
			spot.y = pev->origin.y + dir.y * size + perp.y * shift;
		}
		else if (along < -c45)
		{
			spot.x = pev->origin.x - dir.x * size + perp.x * shift;
			spot.y = pev->origin.y - dir.y * size + perp.y * shift;
		}
		else if (DotProduct(toEnemy, perp) > 0.0)
		{
			spot.x = pev->origin.x + perp.x * size + dir.x * shift;
			spot.y = pev->origin.y + perp.y * size + dir.y * shift;
		}
		else
		{
			spot.x = pev->origin.x - perp.x * size + dir.x * shift;
			spot.y = pev->origin.y - perp.y * size + dir.y * shift;
		}
	}
	else
	{
		const float offset = 200.0f;
		real_t side = RANDOM_FLOAT(-offset, offset) * 2.0f;

		spot.x = pev->origin.x - dir.x * offset + perp.x * side;
		spot.y = pev->origin.y - dir.y * offset + perp.y * side;
	}

	spot.z = pev->origin.z + RANDOM_FLOAT(-50.0, 50.0);

	// we are stunned for a moment
	m_surpriseDelay = RANDOM_FLOAT(0.1, 0.2);
	m_surpriseTimestamp = gpGlobals->time;

	SetLookAt("Panic", &spot, PRIORITY_HIGH, 0, 0, 5.0);
	PrintIfWatched("Aaaah!\n");
}
开发者ID:s1lentq,项目名称:ReGameDLL_CS,代码行数:60,代码来源:cs_bot.cpp

示例13: GetVert

// Pick the best support neighbor along n
// It's critical that this function return an array where the vertices
// are in the proper clockwise order
std::array<vec2, 2> OBB::GetSupportNeighbor(vec2 n, int idx) const {
	std::array<vec2, 2> ret;

	vec2 vb = GetVert(idx);
	vec2 va = GetVert(idx - 1);
	vec2 vc = GetVert(idx + 1);

	vec2 nab = glm::normalize(perp(vb - va));
	vec2 nbc = glm::normalize(perp(vc - vb));
	float d1 = glm::dot(nab, n);
	float d2 = glm::dot(nbc, n);

	if (d1 > d2)
		return{ { va, vb } };
	return{ { vb, vc } };
}
开发者ID:mynameisjohn,项目名称:PyRenderer,代码行数:19,代码来源:OBB.cpp

示例14: intersect2D_2Segments

bool intersect2D_2Segments(Segment s1,Segment s2)//求线的交点
{
    Vector  u,v,w;
    u.x= s1.p2.x-s1.p1.x;
    u.y= s1.p2.y-s1.p1.y;
    v.x= s2.p2.x-s2.p1.x;
    v.y= s2.p2.y-s2.p1.y;
    w.x= s1.p1.x-s2.p1.x;
    w.y= s1.p1.y-s2.p1.y;
    double  D = perp(v,u);
    if (fabs(D) < SMALL_NUM)// S1 and S2 are parallel
            return 0;               // they are NOT collinear
    double sI=perp(w,v)/D;
    I0->x=s1.p1.x+u.x*sI;
    I0->y=s1.p1.y+u.y*sI;
    if(on_segment(s1,*I0)&&on_segment(s2,*I0)) return 1;//判断交点是否在两条线上
    else return 0;
}
开发者ID:Epiphqny,项目名称:MOOC,代码行数:18,代码来源:1.2+Crossroad.cpp

示例15: intersect2dSegPoly

  inline bool intersect2dSegPoly(Vec2r* seg,
				 Vec2r* poly,
				 unsigned n) {
    if (seg[0] == seg[1])
      return false;

    real  tE = 0;             // the maximum entering segment parameter
    real  tL = 1;             // the minimum leaving segment parameter
    real  t, N, D;            // intersect parameter t = N / D
    Vec2r dseg;                // the segment direction vector
    dseg = seg[1] - seg[0];
    Vec2r e;                   // edge vector

    for (unsigned i = 0; i < n; i++) { // process polygon edge poly[i]poly[i+1]
      e = poly[i+1] - poly[i];
      N = perp(e, seg[0] - poly[i]);
      D = -perp(e, dseg);
      if (fabs(D) < M_EPSILON) {
	if (N < 0)
	  return false;
	else
	  continue;
      }

      t = N / D;
      if (D < 0) {       // segment seg is entering across this edge
	if (t > tE) {    // new max tE
	  tE = t;
	  if (tE > tL)   // seg enters after leaving polygon
	    return false;
	}
      }
      else {             // segment seg is leaving across this edge
	if (t < tL) {    // new min tL
	  tL = t;
	  if (tL < tE)   // seg leaves before entering polygon
	    return false;
	}
      }
    }

    // tE <= tL implies that there is a valid intersection subsegment
    return true;
  }
开发者ID:GodZza,项目名称:contours,代码行数:44,代码来源:GeomUtils.cpp


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