本文整理汇总了C++中point2函数的典型用法代码示例。如果您正苦于以下问题:C++ point2函数的具体用法?C++ point2怎么用?C++ point2使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了point2函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: cylinder
void CylinderTest::collisionPoint() {
Shapes::Cylinder3D cylinder({-1.0f, -1.0f, 0.0f}, {1.0f, 1.0f, 0.0f}, 2.0f);
Shapes::Point3D point({2.0f, 0.0f, 0.0f});
Shapes::Point3D point1({1.0f, 3.1f, 0.0f});
Shapes::Point3D point2({2.9f, -1.0f, 0.0f});
VERIFY_COLLIDES(cylinder, point);
VERIFY_COLLIDES(cylinder, point1);
VERIFY_NOT_COLLIDES(cylinder, point2);
}
示例2: ClipToRect
static bool ClipToRect( long & x1, long & y1, long & x2, long & y2,
const WRect & clip )
//-----------------------------------------------------------------
// Cohen-Sutherland Clipping Algorithm from _Fundamentals of Interactive
// Computer Graphics_, page 148.
{
PointCode point1( x1, y1, CL_Inside );
PointCode point2( x2, y2, CL_Inside );
PointCode * p1;
PointCode * p2;
PointCode * tmp;
long top = clip.y();
long left = clip.x();
long bottom = clip.y() + clip.h();
long right = clip.x() + clip.w();
p1 = & point1;
p2 = & point2;
while( 1 ) {
CalcOut( *p1, top, left, bottom, right );
CalcOut( *p2, top, left, bottom, right );
if( p1->code == CL_Inside && p2->code == CL_Inside ) {
return TRUE; // trivial acceptance
}
if( (p1->code & p2->code) != 0 ) {
return FALSE; // trivial rejection
}
if( p1->code == 0 ) { // p1 inside -- swap so p1 outside
tmp = p1;
p1 = p2;
p2 = tmp;
}
// perform a subdivision; move p1 to the intersection point.
// use the formula y = y1 + slope * (x - x1),
// x = x1 + (y - y1) / slope.
if( p1->code & CL_Above ) { // divide at top
p1->x += ((p2->x - p1->x) * (top - p1->y)) / (p2->y - p1->y);
p1->y = top;
} else if( p1->code & CL_Below ) { // divide at bottom of
p1->x += ((p2->x - p1->x) * (bottom - p1->y)) / (p2->y - p1->y);
p1->y = bottom;
} else if( p1->code & CL_Right ) { // divide at right
p1->y += ((p2->y - p1->y) * (right - p1->x)) / (p2->x - p1->x);
p1->x = right;
} else if( p1->code & CL_Left ) { // divide at left
p1->y += ((p2->y - p1->y) * (left - p1->x)) / (p2->x - p1->x);
p1->x = left;
}
}
}
示例3: main
int main(){
int N = 3;
CGAL::Timer cost;
std::vector<Point_d> points;
std::vector<double> point;
point.push_back(6);
point.push_back(6);
point.push_back(6);
Point_d point1(3, point.begin(), point.end());
std::cout << point1[1] << std::endl;
// Point_d point1(1,3,5);
Point_d point2(4,8,10);
Point_d point3(2,7,9);
// Point_d point(1,2,3);
points.push_back(point1);
points.push_back(point2);
points.push_back(point3);
// D Dt(d);
// // CGAL_assertion(Dt.empty());
//
// // insert the points in the triangulation
// cost.reset();cost.start();
// std::cout << " Delaunay triangulation of "<<N<<" points in dim "<<d<< std::flush;
// std::vector<Point_d>::iterator it;
// for(it = points.begin(); it!= points.end(); ++it){
// Dt.insert(*it);
// }
// std::list<Simplex_handle> NL = Dt.all_simplices(D::NEAREST);
// std::cout << " done in "<<cost.time()<<" seconds." << std::endl;
// CGAL_assertion(Dt.is_valid() );
// CGAL_assertion(!Dt.empty());
//
//
// Vertex_handle v = Dt.nearest_neighbor(point);
// Simplex_handle s = Dt.simplex(v);
//
// std::vector<Point_d> Simplex_vertices;
// for(int j=0; j<=d; ++j){
// Vertex_handle vertex = Dt.vertex_of_simplex(s,j);
// Simplex_vertices.push_back(Dt.associated_point(vertex));
// }
//
// std::vector<K::FT> coords;
// K::Barycentric_coordinates_d BaryCoords;
// BaryCoords(Simplex_vertices.begin(), Simplex_vertices.end(),point,std::inserter(coords, coords.begin()));
// std::cout << coords[0] << std::endl;
// return 0;
}
示例4: min
// track object
void ObjectTrackingClass::track(cv::Mat& image, // output image
cv::Mat& image1, // previous frame
cv::Mat& image2, // next frame
std::vector<cv::Point2f>& points1, // previous points
std::vector<cv::Point2f>& points2, // next points
std::vector<uchar>& status, // status array
std::vector<float>& err) // error array
{
// tracking code
cv::calcOpticalFlowPyrLK(image1,
image2,
points1,
points2,
status,
err,
winSize,
maxLevel,
termcrit,
flags,
minEigThreshold);
// work out maximum X,Y keypoint values in the next_points keypoint vector
cv::Point2f min(FLT_MAX, FLT_MAX);
cv::Point2f max(FLT_MIN, FLT_MIN);
// refactor the points array to remove points lost due to tracking error
size_t i, k;
for( i = k = 0; i < points2.size(); i++ )
{
if( !status[i] )
continue;
points2[k++] = points2[i];
// find keypoints at the extremes
min.x = Min(min.x, points2[i].x);
min.y = Min(min.y, points2[i].y);
max.x = Max(max.x, points2[i].x);
max.y = Max(max.y, points2[i].y);
// draw points
cv::circle( image, points2[i], 3, cv::Scalar(0,255,0), -1, 8);
}
points2.resize(k);
// Draw lines between the extreme points (square)
cv::Point2f point0(min.x, min.y);
cv::Point2f point1(max.x, min.y);
cv::Point2f point2(max.x, max.y);
cv::Point2f point3(min.x, max.y);
cv::line( image, point0, point1, cv::Scalar( 0, 255, 0 ), 4 );
cv::line( image, point1, point2, cv::Scalar( 0, 255, 0 ), 4 );
cv::line( image, point2, point3, cv::Scalar( 0, 255, 0 ), 4 );
cv::line( image, point3, point0, cv::Scalar( 0, 255, 0 ), 4 );
}
示例5: saveGlobalState
//-----------------------------------------------------------------------------
void D2DDrawContext::drawPoint (const CPoint &point, const CColor& color)
{
saveGlobalState ();
setLineWidth (1);
setFrameColor (color);
CPoint point2 (point);
point2.h++;
moveTo (point);
lineTo (point2);
restoreGlobalState ();
}
示例6: TestEndPosition
void TestEndPosition()
{
osg::Vec3 point1(0.0f, 0.0f, 0.0f);
osg::Vec3 point2(10.0f, 10.0f, 10.0f);
mIsector->SetStartPosition(point1);
mIsector->SetEndPosition(point2);
CPPUNIT_ASSERT(mIsector->GetDirection() == (point2 - point1));
CPPUNIT_ASSERT_DOUBLES_EQUAL( mIsector->GetLength(), mIsector->GetDirection().length(), 0.001f );
}
示例7: sin
point2 point2::rotate_relative_to(double angle, point2 const& p) const
{
double ox = p.x;
double oy = p.y;
double v1 = sin(angle);
double v2 = cos(angle);
double v3 = -oy + y;
double v4 = -ox + x;
return point2(ox - v1*v3 + v2*v4, oy + v2*v3 + v1*v4);
}
示例8: contain
bool RTRBoundingBox::contain(const RTRBoundingBox& other) const
{
for (int i = 0; i < 3; i++)
{
if (point1(i)>other.point1(i) || point2(i) < other.point2(i))
{
return false;
}
}
return true;
}
示例9: GetWindowMatrix
FX_BOOL CPWL_EditCtrl::IsWndHorV()
{
CPDF_Matrix mt = GetWindowMatrix();
CPDF_Point point1(0,1);
CPDF_Point point2(1,1);
mt.Transform(point1.x, point1.y);
mt.Transform(point2.x, point2.y);
return point2.y == point1.y;
}
示例10: saveGlobalState
//-----------------------------------------------------------------------------
void CGDrawContext::drawPoint (const CPoint &point, const CColor& color)
{
saveGlobalState ();
setLineWidth (1);
setFrameColor (color);
CPoint point2 (point);
point2.x++;
COffscreenContext::drawLine (point, point2);
restoreGlobalState ();
}
示例11: vertice_gradient
// gradient influence of vertex vx,vt to point y
double vertice_gradient(int vx, int vy, double x, double y) const
{
// distance
auto dx = x - vx;
auto dy = y - vy;
vx = (vx == W) ? 0 : vx;
vy = (vy == H) ? 0 : vy;
const gradient &g = m_matrix[point2(vx, vy)];
return dx * g.x + dy * g.y;
}
示例12: drawTree2D
void drawTree2D(const std::vector<std::shared_ptr<Node<dim>>> &nodes, cv::Mat &image, Eigen::Vector3i colorNode,
Eigen::Vector3i colorEdge, int thickness) {
static_assert(dim == 2, "Dimension has to be 2");
for (auto &elem : nodes) {
cv::Point point(elem->getValue(0), elem->getValue(1));
// cv::circle(image, point, 3, cv::Scalar(colorNode[0], colorNode[1], colorNode[2]), 1);
if (elem->getParentNode() != nullptr) {
cv::Point point2(elem->getParentNode()->getValue(0), elem->getParentNode()->getValue(1));
cv::line(image, point, point2, cv::Scalar(colorEdge[0], colorEdge[1], colorEdge[2]), thickness);
}
}
}
示例13: main
int main(int argc, char **argv) {
std::cout
<< "¸.·´¯`·.¸¸.·´ BioFractalTree Version 0 Revision 1 `·.¸¸.·´¯`·.¸\n";
// set up a bcurve for testing early curve / surface viz algs
vector<double> coords0 = { 0.0, 0.0, 0.0 };
vector<double> coords1 = { 0.0, 0.3, 0.3 };
vector<double> coords2 = { 0.3, 0.0, 0.6 };
vector<double> coords3 = { 0.0, 0.0, 1.0 };
std::unique_ptr<point> point0(new point(coords0, 0));
std::unique_ptr<point> point1(new point(coords1, 1));
std::unique_ptr<point> point2(new point(coords2, 2));
std::unique_ptr<point> point3(new point(coords3, 3));
vector<point> curve0 = { *point0, *point1, *point2, *point3 };
std::unique_ptr<bcurve> thisCurve(new bcurve(curve0, 20));
// we set up a static Bernstein basis set for a given resolution
std::unique_ptr<bBasis> bBasis_20(new bBasis(20));
// this sets up a 4x21 vector of vector<double>
// 19 internal points plus the two endpoints
// we can return / output the basis set
vector<vector<double> > returnBasis;
bBasis_20->getBasis(returnBasis);
// std::cout << "Basis Set Output: \n";
// std::cout << " size : " << returnBasis.at(0).size();
for (int j = 0; j < 4; j++) {
// std::cout << "\n b[" << j << "] : ";
for (int i = 0; i < returnBasis.at(j).size(); i++) {
// std::cout << returnBasis.at(j).at(i) << " ";
}
}
// std::cout << "\n";
// now we can try getting some points on the bcurve
vector<point> returnPoints;
thisCurve->getPointsOnCurve(returnPoints, returnBasis, 4);
// only returnPoints gets modified by the above function
// it returns 21 points along the curve, including endpoints
std::cout << "points on curve : \n";
for (int i = 0; i < returnPoints.size(); i++) {
vector<double> tempCoord;
returnPoints.at(i).getCoord(tempCoord);
for (int j = 0; j < 3; j++) {
std::cout << tempCoord.at(j) << " ";
}
std::cout << "\n";
}
return 0;
}
示例14: TEST
// TODO: Uncomment and fix, see issue #339
TEST(PathConstructor, TestConstructPath) {
/* origin of OccupancyGrid */
// initialize origin of occupancy grid
geometry_msgs::Pose origin =
PathFinderTestUtils::constructPose(3.0, 3.0, 0.0);
/* mapMetaData of OccupancyGrid */
// initialize mapMetaData
nav_msgs::MapMetaData map_meta_data;
map_meta_data.resolution = 2.0;
map_meta_data.width = 2;
map_meta_data.height = 2;
// add origin to mapMetaData
map_meta_data.origin = origin;
/* OccupancyGridAdapter */
std::shared_ptr<OccupancyGridAdapter> occupancy_grid_adapter_ptr(
new OccupancyGridAdapter(map_meta_data));
/* first point in path*/
AStar::GridPoint point1(-99 - sqrt(3), -99 - 1);
/* second point in path*/
AStar::GridPoint point2(-99, -99);
/* add points to path */
std::stack<AStar::GridPoint> points;
points.push(point1);
points.push(point2);
PathConstructor path_constructor(occupancy_grid_adapter_ptr);
nav_msgs::Path path = path_constructor.constructPath(points);
tf::Quaternion q1;
tf::quaternionMsgToTF(path.poses[0].pose.orientation, q1);
/* we lose resolution by converting a point into a grid, so allow more
error
*/
EXPECT_NEAR(q1.getAngle(), M_PI + M_PI / 6, 0.5);
EXPECT_FLOAT_EQ(
path.poses[0].pose.position.x,
occupancy_grid_adapter_ptr->convertFromGridToMapPoint(point2).x);
EXPECT_FLOAT_EQ(
path.poses[0].pose.position.y,
occupancy_grid_adapter_ptr->convertFromGridToMapPoint(point2).y);
EXPECT_FLOAT_EQ(
path.poses[1].pose.position.x,
occupancy_grid_adapter_ptr->convertFromGridToMapPoint(point1).x);
EXPECT_FLOAT_EQ(
path.poses[1].pose.position.y,
occupancy_grid_adapter_ptr->convertFromGridToMapPoint(point1).y);
}
示例15: box
void AxisAlignedBoxTest::collisionPoint() {
Physics::AxisAlignedBox3D box({-1.0f, -2.0f, -3.0f}, {1.0f, 2.0f, 3.0f});
Physics::Point3D point1({-1.5f, -1.0f, 2.0f});
Physics::Point3D point2({0.5f, 1.0f, -2.5f});
randomTransformation(box);
randomTransformation(point1);
randomTransformation(point2);
VERIFY_NOT_COLLIDES(box, point1);
VERIFY_COLLIDES(box, point2);
}