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


C++ ObjectType::height方法代码示例

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


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

示例1: worldToScreenCoords

static Rect worldToScreenCoords(const Point3f &_position, const ObjectType &_type, const Point2f &fov_size, const Size &frame_size, float cameraElevation)
{
	// TODO : replace magic numbers with an object depth property
	// This constant is half a ball diameter (9.75-ish inches), converted to meters
	// For example, goals will have 0 depth since we're just shooting at
	// a plane. 3d objects will have depth, though, so we track the center of the
	// rather than the front.
	float r = sqrtf(_position.x * _position.x + _position.y * _position.y + _position.z * _position.z); // - (4.572 * 25.4)/1000.0;
	float azimuth = asinf(_position.x / sqrt(_position.x * _position.x + _position.y * _position.y));
	float inclination = asinf( _position.z / r ) + cameraElevation;

	//inverse of formula in screenToWorldCoords()
	Point2f dist_to_center(
			tan(azimuth) * (0.5 * frame_size.width / tan(fov_size.x / 2)),
			tan(inclination) * (0.5 * frame_size.height / tan(fov_size.y / 2)));
	
	cout << "Distance to center: " << dist_to_center << endl;
	Point2f rect_center(
			dist_to_center.x + (frame_size.width / 2.0),
			-dist_to_center.y + (frame_size.height / 2.0));

	Point2f angular_size( 2.0 * atan2f(_type.width(), (2.0*r)), 2.0 * atan2f(_type.height(), (2.0*r)));
	Point2f screen_size(
			angular_size.x * (frame_size.width / fov_size.x),
			angular_size.y * (frame_size.height / fov_size.y));

	Point topLeft(
			cvRound(rect_center.x - (screen_size.x / 2.0)),
			cvRound(rect_center.y - (screen_size.y / 2.0)));
			return Rect(topLeft.x, topLeft.y, cvRound(screen_size.x), cvRound(screen_size.y));
}
开发者ID:FRC900,项目名称:2016VisionCode,代码行数:31,代码来源:track3d.cpp


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