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


C++ Point2类代码示例

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


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

示例1: Size2

void Sprite::_get_rects(Rect2 &r_src_rect, Rect2 &r_dst_rect, bool &r_filter_clip) const {

	Size2 s;
	r_filter_clip = false;

	if (region) {

		s = region_rect.size;
		r_src_rect = region_rect;
		r_filter_clip = region_filter_clip;
	} else {
		s = Size2(texture->get_size());
		s = s / Size2(hframes, vframes);

		r_src_rect.size = s;
		r_src_rect.position.x = float(frame % hframes) * s.x;
		r_src_rect.position.y = float(frame / hframes) * s.y;
	}

	Point2 ofs = offset;
	if (centered)
		ofs -= s / 2;
	if (Engine::get_singleton()->get_use_pixel_snap()) {
		ofs = ofs.floor();
	}

	r_dst_rect = Rect2(ofs, s);

	if (hflip)
		r_dst_rect.size.x = -r_dst_rect.size.x;
	if (vflip)
		r_dst_rect.size.y = -r_dst_rect.size.y;
}
开发者ID:Ranakhamis,项目名称:godot,代码行数:33,代码来源:sprite.cpp

示例2: midpoint2

inline
Point2
midpoint2(const Point2 &p, const Point2 &q)
{
  // return Point2((p.x_ref() + q.x_ref())/FT(2),(p.y_ref() + q.y_ref())/FT(2));
  return Point2((p.x() + q.x())/FT(2), (p.y() + q.y())/FT(2));
}
开发者ID:ArcEarth,项目名称:cgal,代码行数:7,代码来源:tst10.cpp

示例3: draw

void Cube::draw(Mat4x4 projection, Mat4x4 modelView, Mat4x4 world, Point2 color, Point2 camPos, Point2 camDir)
{
	// Activation du shader
	glUseProgram(m_shader.getProgramID());

	// Verrouillage du VAO
	glBindVertexArray(m_vaoID);

	// Envoi des matrices
	glUniformMatrix4fv(glGetUniformLocation(m_shader.getProgramID(), "u_projection"), 1, GL_FALSE, projection.getMatrix());
	glUniformMatrix4fv(glGetUniformLocation(m_shader.getProgramID(), "u_modelView"), 1, GL_FALSE, modelView.getMatrix());
	glUniformMatrix4fv(glGetUniformLocation(m_shader.getProgramID(), "u_world"), 1, GL_FALSE, world.getMatrix());
	glUniform3f(glGetUniformLocation(m_shader.getProgramID(), "u_camPos"), camPos.Getx(), camPos.Gety(), camPos.Getz());
	glUniform3f(glGetUniformLocation(m_shader.getProgramID(), "u_camPos"), camDir.Getx(), camDir.Gety(), camDir.Getz());
	glUniform3f(glGetUniformLocation(m_shader.getProgramID(), "u_color"), color.Getx(), color.Gety(), color.Getz());


	// Rendu
	glDrawElements(GL_TRIANGLES, m_indicesTriangle.size(), GL_UNSIGNED_SHORT, 0);

	// Déverrouillage du VAO
	glBindVertexArray(0);

	// Désactivation du shader
	glUseProgram(0);
}
开发者ID:BourotBenjamin,项目名称:Space_Wars,代码行数:26,代码来源:Cube.cpp

示例4: VectorMeters2NorthHeading

double VectorMeters2NorthHeading(const Point2& ref, const Point2& p, const Vector2& dir)
{
	double h = atan2(dir.dx, dir.dy) * RAD_TO_DEG;
	if (h < 0.0) h += 360.0;
	double lon_delta = p.x() - ref.x();
	return h + lon_delta * sin(p.y() * DEG_TO_RAD);
}
开发者ID:highattack30,项目名称:xptools,代码行数:7,代码来源:GISUtils.cpp

示例5: windowPos

/******************************************************************************
* Renders the image in a rectangle given in viewport coordinates.
******************************************************************************/
void DefaultImagePrimitive::renderViewport(SceneRenderer* renderer, const Point2& pos, const Vector2& size)
{
	QSize imageSize = renderer->outputSize();
	Point2 windowPos((pos.x() + 1.0f) * imageSize.width() / 2, (-(pos.y() + size.y()) + 1.0) * imageSize.height() / 2);
	Vector2 windowSize(size.x() * imageSize.width() / 2, size.y() * imageSize.height() / 2);
	renderWindow(renderer, windowPos, windowSize);
}
开发者ID:bitzhuwei,项目名称:OVITO_sureface,代码行数:10,代码来源:DefaultImagePrimitive.cpp

示例6: edgeDistance

double edgeDistance(Point2 p1, Point2 p2, Point2 p)
{
	double x1 = p1.x;
	double x2 = p2.x;
	double y1 = p1.y;
	double y2 = p2.y;

	double x0 = p.x;
	double y0 = p.y;

	double den = fabs((y2 - y1)*x0 - (x2-x1)*y0 + x2*y1-y2*x1);
	double num = sqrt((y2-y1)*(y2-y1) + (x2-x1)*(x2-x1));


	double linedist = den / num;

	double p1_dist = p1.distance(p);
	double p2_dist = p2.distance(p);
	double edge_len = p1.distance(p2);

	if (p1_dist > edge_len)
		return std::numeric_limits<double>::infinity();

	if (p2_dist > edge_len)
		return std::numeric_limits<double>::infinity();

	return linedist;
}
开发者ID:maximlevitsky,项目名称:animations-editor-bdmorph,代码行数:28,代码来源:utils.cpp

示例7:

pscalar PointSolver::LineSegment2D::errorJacobian (Point2 &P, pscalar *jm)
{
	pscalar lsegmentsq = this->lengthSquared();

	pscalar dep1x, dep1y, dep2x, dep2y;
	pscalar p1x = A.coord.x(),
			p1y = A.coord.y(),
			p2x = B.coord.x(),
			p2y = B.coord.y(),
			px = P.x(), py = P.y();

	dep1x = -2*(p2y-p1y)*
		(p2x*py-p1x*py-p2y*px+p1y*px+p1x*p2y-p1y*p2x) *
		(p2y*py-p1y*py+p2x*px-p1x*px-p2y*p2y+p1y*p2y-p2x*p2x+p1x*p2x) /
		(lsegmentsq * lsegmentsq);
	dep1y = 2*(p2x-p1x)*
		(p2x*py-p1x*py-p2y*px+p1y*px+p1x*p2y-p1y*p2x) *
		(p2y*py-p1y*py+p2x*px-p1x*px-p2y*p2y+p1y*p2y-p2x*p2x+p1x*p2x) /
		(lsegmentsq * lsegmentsq);
	dep2x = 2*(p2y-p1y)*
		(p2x*py-p1x*py-p2y*px+p1y*px+p1x*p2y-p1y*p2x) *
		(p2y*py-p1y*py+p2x*px-p1x*px-p1y*p2y-p1x*p2x+p1y*p1y+p1x*p1x) /
		(lsegmentsq * lsegmentsq);
	dep2y = -2*(p2x-p1x)*
		(p2x*py-p1x*py-p2y*px+p1y*px+p1x*p2y-p1y*p2x)*
		(p2y*py-p1y*py+p2x*px-p1x*px-p1y*p2y-p1x*p2x+p1y*p1y+p1x*p1x) /
		(lsegmentsq * lsegmentsq);

	for (int i=0; i<7; i++) {
		jm[i] = dep1x*A.jacobian[i][0] + dep1y*A.jacobian[i][1] + dep2x*B.jacobian[i][0] + dep2y*B.jacobian[i][1];
	}
}
开发者ID:sujiwo,项目名称:vector-map-localization,代码行数:32,代码来源:PointSolver.cpp

示例8: Point2

/* ************************************************************************* */
Point2 Cal3Bundler::uncalibrate(const Point2& p, //
    boost::optional<Matrix&> Dcal, boost::optional<Matrix&> Dp) const {
  //  r = x^2 + y^2;
  //  g = (1 + k(1)*r + k(2)*r^2);
  //  pi(:,i) = g * pn(:,i)
  const double x = p.x(), y = p.y();
  const double r = x * x + y * y;
  const double g = 1. + (k1_ + k2_ * r) * r;
  const double u = g * x, v = g * y;

  // Derivatives make use of intermediate variables above
  if (Dcal) {
    double rx = r * x, ry = r * y;
    Dcal->resize(2, 3);
    *Dcal << u, f_ * rx, f_ * r * rx, v, f_ * ry, f_ * r * ry;
  }

  if (Dp) {
    const double a = 2. * (k1_ + 2. * k2_ * r);
    const double axx = a * x * x, axy = a * x * y, ayy = a * y * y;
    Dp->resize(2,2);
    *Dp << g + axx, axy, axy, g + ayy;
    *Dp *= f_;
  }

  return Point2(u0_ + f_ * u, v0_ + f_ * v);
}
开发者ID:DForger,项目名称:gtsam,代码行数:28,代码来源:Cal3Bundler.cpp

示例9: invKPi

/* ************************************************************************* */
Point2 Cal3Bundler::calibrate(const Point2& pi, const double tol) const {
  // Copied from Cal3DS2 :-(
  // but specialized with k1,k2 non-zero only and fx=fy and s=0
  const Point2 invKPi((pi.x() - u0_)/f_, (pi.y() - v0_)/f_);

  // initialize by ignoring the distortion at all, might be problematic for pixels around boundary
  Point2 pn = invKPi;

  // iterate until the uncalibrate is close to the actual pixel coordinate
  const int maxIterations = 10;
  int iteration;
  for (iteration = 0; iteration < maxIterations; ++iteration) {
    if (uncalibrate(pn).distance(pi) <= tol)
      break;
    const double x = pn.x(), y = pn.y(), xx = x * x, yy = y * y;
    const double rr = xx + yy;
    const double g = (1 + k1_ * rr + k2_ * rr * rr);
    pn = invKPi / g;
  }

  if (iteration >= maxIterations)
    throw std::runtime_error(
        "Cal3DS2::calibrate fails to converge. need a better initialization");

  return pn;
}
开发者ID:DForger,项目名称:gtsam,代码行数:27,代码来源:Cal3Bundler.cpp

示例10: Pose2betweenOptimized

/* ************************************************************************* */
Pose2 Pose2betweenOptimized(const Pose2& r1, const Pose2& r2,
                            boost::optional<Matrix3&> H1, boost::optional<Matrix3&> H2)
{
    // get cosines and sines from rotation matrices
    const Rot2& R1 = r1.r(), R2 = r2.r();
    double c1=R1.c(), s1=R1.s(), c2=R2.c(), s2=R2.s();

    // Assert that R1 and R2 are normalized
    assert(std::abs(c1*c1 + s1*s1 - 1.0) < 1e-5 && std::abs(c2*c2 + s2*s2 - 1.0) < 1e-5);

    // Calculate delta rotation = between(R1,R2)
    double c = c1 * c2 + s1 * s2, s = -s1 * c2 + c1 * s2;
    Rot2 R(Rot2::atan2(s,c)); // normalizes

    // Calculate delta translation = unrotate(R1, dt);
    Point2 dt = r2.t() - r1.t();
    double x = dt.x(), y = dt.y();
    Point2 t(c1 * x + s1 * y, -s1 * x + c1 * y);

    // FD: This is just -AdjointMap(between(p2,p1)) inlined and re-using above
    if (H1) {
        double dt1 = -s2 * x + c2 * y;
        double dt2 = -c2 * x - s2 * y;
        *H1 = Matrix3();
        (*H1) <<
              -c,  -s,  dt1,
              s,  -c,  dt2,
              0.0, 0.0,-1.0;
    }
    if (H2) *H2 = Matrix3::Identity();

    return Pose2(R,t);
}
开发者ID:exoter-rover,项目名称:slam-gtsam,代码行数:34,代码来源:timePose2.cpp

示例11: H

    Matrix H(const Point2& x_t1) const {
        // Update Jacobian
        Matrix H(1,2);
        H(0,0) =  4*x_t1.x() - x_t1.y() - 2.5;
        H(0,1) = -1*x_t1.x() + 7;

        return H;
    }
开发者ID:exoter-rover,项目名称:slam-gtsam,代码行数:8,代码来源:testExtendedKalmanFilter.cpp

示例12: NorthHeading2VectorDegs

void NorthHeading2VectorDegs(const Point2& ref, const Point2& p, double heading, Vector2& dir)
{
	double lon_delta = p.x() - ref.x();
	double real_heading = heading - lon_delta * sin(p.y() * DEG_TO_RAD);

	dir.dx = sin(real_heading * DEG_TO_RAD) / cos (ref.y() * DEG_TO_RAD);
	dir.dy = cos(real_heading * DEG_TO_RAD);
}
开发者ID:highattack30,项目名称:xptools,代码行数:8,代码来源:GISUtils.cpp

示例13: midpoint1

inline
Point2
midpoint1(const Point2 &p, const Point2 &q)
{
  FT x,y;
  midpointC2(p.x(),p.y(),q.x(),q.y(),x,y);
  return Point2(x,y);
}
开发者ID:ArcEarth,项目名称:cgal,代码行数:8,代码来源:tst10.cpp

示例14: getCode

unsigned char getCode(Point2 p)				//This function returns a bitwise OR value
{
	unsigned char code = 0;
	if(p.getX()<LEFT)   code |= 8;			//if on the left, then TFFF or 1000
	if(p.getY()>TOP)    code |= 4;			//if on the top, then FTFF or 0100
	if(p.getX()>RIGHT)  code |= 2;			//if on the right, then FFTF or 0010
	if(p.getY()<BOTTOM) code |= 1;			//if on the bottom, then FFFT or 0001
	return code;							
}
开发者ID:rckclmbr,项目名称:Joshs-School,代码行数:9,代码来源:TeamProject2.cpp

示例15: assertEqualsImpl

void TestCase::assertEqualsImpl(const Point2 &actual, const Point2 &expected, Float epsilon, const char *file, int line) {
	bool match = true;
	for (int i=0; i<2; ++i)
		if (std::abs(actual[i]-expected[i]) > epsilon)
			match = false;
	if (!match)
		Thread::getThread()->getLogger()->log(EError, NULL, file, line, "Assertion failure: "
			"expected point %s, got %s.", expected.toString().c_str(), actual.toString().c_str());
}
开发者ID:blckshrk,项目名称:IFT6042,代码行数:9,代码来源:testcase.cpp


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