本文整理汇总了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));
}