本文整理汇总了C++中point::real方法的典型用法代码示例。如果您正苦于以下问题:C++ point::real方法的具体用法?C++ point::real怎么用?C++ point::real使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类point
的用法示例。
在下文中一共展示了point::real方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PointLineDistance
double PointLineDistance(const point &a, const point &b, const point &p,
point &res) {
double scale = dot(vec(a,b),vec(a,p)) / lengthSqr(vec(a,b));
res.real() = a.real() + scale * (b.real() - a.real());
res.imag() = a.imag() + scale * (b.imag() - a.imag());
return dist(p, res);
}
示例2: pointsToLine
line pointsToLine(point a, point b) {
line result;
result.a=b.imag()-a.imag();
result.b=a.real()-b.real();
result.c=a.imag()*b.real()-a.real()*b.imag();
return result;
}
示例3: get_angle
double get_angle(point a, point b, point c) {
double ux = b.real() - a.real();
double uy = b.imag() - a.imag();
double vx = c.real() - a.real();
double vy = c.imag() - a.imag();
return acos(
(ux * vx + uy * vy)
/ sqrt((ux * ux + uy * uy) * (vx * vx + vy * vy)));
}
示例4: turn
int turn(point O, point A, point B) {
double res = (A.real() - O.real()) * (B.imag() - O.imag())
- (A.imag() - O.imag()) * (B.real() - O.real());
if (res < 0)
return -1;
if (res > 0)
return 1;
return 0;
}
示例5: cmpAngle
bool cmpAngle(point a, point b) {
if (collinear(pivot, a, b))
return distsqr(pivot,a) < distsqr(pivot, b);
// return ccw(pivot, a, b);
double d1x = a.real() - pivot.real();
double d1y = a.imag() - pivot.imag();
double d2x = b.real() - pivot.real();
double d2y = b.imag() - pivot.imag();
return (atan2(d1y, d1x) - atan2(d2y, d2x) < 0);
}
示例6: inPolygon
bool inPolygon(point P, vector<point> poly) {
bool in = 0;
int n = poly.size();
for (int i = 0, j = n - 1; i < n; j = i++) {
if ((poly[i].imag() <= P.imag() + eps && P.imag() < poly[j].imag())
|| (poly[j].imag() <= P.imag() + eps
&& P.imag() < poly[i].imag())) {
if (P.real() - eps
< (poly[j].real() - poly[i].real())
* (P.imag() - poly[i].imag())
/ (poly[j].imag() - poly[i].imag())
+ poly[i].real())
in ^= 1;
}
}
return in;
}
示例7: closestPoint
point closestPoint(line l, point p) {
ld d=l.a*l.a+l.b*l.b;
point result( (l.b*l.b*p.real()-l.a*l.c-l.a*l.b*p.imag())/d ,
(l.a*l.a*p.imag()-l.b*l.c-l.a*l.b*p.real())/d );
return result;
}
示例8: cross_p
double cross_p(point p, point q, point r) {
return (r.real() - q.real()) * (p.imag() - q.imag())
- (r.imag() - q.imag()) * (p.real() - q.real());
}
示例9: crossProd
int crossProd(point a, point b) {
return a.real() * b.imag() - a.imag() * b.real();
}
示例10: cmpPoint
bool cmpPoint(point a, point b) {
if (a.real() == b.real())
return a.imag() < b.imag();
return a.real() < b.real();
}
示例11: display1
void display1()
{
vector<double> color;
double low = (vh[0]+0.9)/map_a/1.8 - map_b;
double high = (vh[1]+0.9)/map_a/1.8 - map_b;
// style
glLineWidth(1);
glPointSize(3);
// ground
const double gsize = 50.0;
double gr_x = floor(robot.x);
double gr_y = floor(robot.y);
setColor(config["ground-panel"]);
glBegin(GL_POLYGON);
glVertex3d(gr_x+gsize, gr_y+gsize, 0.0);
glVertex3d(gr_x-gsize, gr_y+gsize, 0.0);
glVertex3d(gr_x-gsize, gr_y-gsize, 0.0);
glVertex3d(gr_x+gsize, gr_y-gsize, 0.0);
glEnd();
setColor(config["ground-line"]);
glBegin(GL_LINES);
for(int i=-gsize; i<=gsize; i++)
{
glVertex3d(gr_x+i*1.0, gr_y-gsize, 0.0);
glVertex3d(gr_x+i*1.0, gr_y+gsize, 0.0);
glVertex3d(gr_x-gsize, gr_y+i*1.0, 0.0);
glVertex3d(gr_x+gsize, gr_y+i*1.0, 0.0);
}
glEnd();
// style
glLineWidth(3);
// robot
glColor3d(1.0, 1.0, 1.0);
drowCross(robot, glpos.data.theta, 1.0);
// adjust
if(disp_lajst)
{
glColor3d(0.0, 1.0, 1.0);
drowCross(triple(lajst.data.x, lajst.data.y, 0.0), lajst.data.theta, 0.5);
}
if(disp_eajst)
{
glColor3d(0.0, 1.0, 0.0);
drowCross(triple(eajst.data.x, eajst.data.y, 0.0), eajst.data.theta, 0.5);
}
#ifdef MERGEDEBUG
glColor3d(1.0, 0.0, 1.0);
drowCross(triple(mergecenter.real(), mergecenter.imag(), 0.0), eajst.data.theta, 0.5);
#endif
// gridmap
if(disp_map)
{
color = config["map-points"];
glBegin(GL_POINTS);
for(int i=0; i<gridmap.size(); i++)
{
if(low<=gridmap[i].z && gridmap[i].z<=high)
{
setColor(color, map_a*(map_b+gridmap[i].z));
if(view2d) glVertex2dv(gridmap[i].vec);
else glVertex3dv(gridmap[i].vec);
}
}
glEnd();
}
// scan data
for(int i=0; i<stream_num; i++)
{
// scan point
if(!disp_sdata[i]) continue;
glBegin(GL_POINTS);
color = config[strprintf("urg-points-%d",i)];
for(int j=0; j<sdata[i].property.numPoints; j++)
{
if(sdata[i].data[j].isError()) continue;
triple ref(sdata[i].data[j].reflect.vec);
if(low<=ref.z && ref.z<=high)
{
ref.rotZ(glpos.data.theta);
setColor(color, map_a*(map_b+ref.z));
glVertex3dv( (robot+ref).vec );
}
}
glEnd();
// scan laser
if(!disp_laser) continue;
//.........这里部分代码省略.........
示例12: operator
bool operator()(const point &a, const point &b) const
{
if (!Equal(a.real(), b.real()))
return a.real() < b.real();
return a.imag() < b.imag();
}
示例13: cross
double cross(point a, point b)
{
return (a.real() * b.imag() - a.imag() * b.real());
}
示例14: dot
double dot(point a, point b)
{
return (a.real() * b.real() + a.imag() * b.imag());
}
示例15:
inline
bool operator < (point a, point b){
if(a.real() != b.real())return a.real() < b.real();
return a.imag() < b.imag();
}