本文整理汇总了C++中TransformPoint函数的典型用法代码示例。如果您正苦于以下问题:C++ TransformPoint函数的具体用法?C++ TransformPoint怎么用?C++ TransformPoint使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了TransformPoint函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LineHitsObject
//test for line-of-sight - face intersection is hard, so cheat slightly
//and look along the y=0 base plane for a line intersection.
//Returns index of first object hit.
int LineHitsObject(Point3d gunPoint, Point3d gunAngle) {
int i, j, ret;
float nearest, distance;
Point3d start, end;
ret=0;
nearest=0.0;
//Cycle through objects
for (i=1; i<=world.numObjects; i++) {
//cycle through edges
for (j=0; j < world.objects[i].numEdges;j++) {
//transform with respect to the gun position and orientation
start=TransformPoint(world.objects[i].points[world.objects[i].edges[j].start], gunPoint, gunAngle);
end=TransformPoint(world.objects[i].points[world.objects[i].edges[j].end], gunPoint, gunAngle);
//ignore height - if the edge's start and end points are left and right of the gun, and in front, it's a hit
if (((start.x <=0 && end.x >= 0) || (start.x >=0 && end.x <= 0)) && start.z >0 && end.z > 0) {
//Hit! Is it nearer than the last one?
distance = start.z;
if (start.x != end.x)
distance += start.x * (end.z - start.z) / (end.x - start.x);
if (ret==0 || distance < nearest) {
ret=i;
nearest = distance;
break; //jump out of for loop (for j)
}
}
}
}
return ret; //will be 0 if none found - our objects start at 1 anyway
}
示例2: EnterCriticalSection
void CGraph::DrawPoint()
{
EnterCriticalSection(&m_cs);
if(m_iGraphPointCurrentNum != 0)
{
m_hOldDrawPointPen = (HPEN)::SelectObject(m_hMemDC, m_hDrawPointPen);
//计算比例
for(std::deque<GraphDataInfoStruct>::size_type i = 0; i < m_iGraphPointCurrentNum; ++i)
{
GraphDataInfoStruct gd = m_GraphDataInfoStructDeque[i];
double gdPoint[CNC_AXIS_NUM];
memcpy(gdPoint, gd.nAxisRealPos, sizeof(double) * CNC_AXIS_NUM);
RefreshPointMinAndMax(gdPoint);
double xRate = (m_GraphPointMaxX - m_GraphPointMinX) / m_cxExcludeFrameStaticWidth;
double yRate = (m_GraphPointMaxY - m_GraphPointMinY) / m_cyExcludeFrameStaticHeight;
//fTempRate = xRate >= yRate ? xRate : yRate;
//g_fRate = g_fRate > fTempRate ? g_fRate : fTempRate;
g_fRate = xRate >= yRate ? xRate : yRate;
}
for(std::deque<GraphDataInfoStruct>::size_type i = 0; i < m_iGraphPointCurrentNum - 1; ++i)
{
GraphDataInfoStruct gd1 = m_GraphDataInfoStructDeque[i];
GraphDataInfoStruct gd2 = m_GraphDataInfoStructDeque[i + 1];
double BeforeTransformGd1Point[CNC_AXIS_NUM], BeforeTransformGd2Point[CNC_AXIS_NUM];
memcpy(BeforeTransformGd1Point, gd1.nAxisRealPos, sizeof(double) * CNC_AXIS_NUM);
memcpy(BeforeTransformGd2Point, gd2.nAxisRealPos, sizeof(double) * CNC_AXIS_NUM);
////获取区域大小
//RefreshPointMinAndMax(BeforeTransformGd1Point);
//RefreshPointMinAndMax(BeforeTransformGd2Point);
double *AfterTransformGd1Point = TransformPoint(BeforeTransformGd1Point);
double *AfterTransformGd2Point = TransformPoint(BeforeTransformGd2Point);
//为防止像素点为同一点,过滤
if(fabs(int(AfterTransformGd2Point[0]) * 1.0 - int(AfterTransformGd1Point[0]) * 1.0) >= 1.0 ||
fabs(int(AfterTransformGd2Point[1]) * 1.0 - int(AfterTransformGd1Point[1]) * 1.0) >= 1.0)
{
::MoveToEx(m_hMemDC, AfterTransformGd1Point[0], AfterTransformGd1Point[1], NULL);
::LineTo(m_hMemDC, AfterTransformGd2Point[0], AfterTransformGd2Point[1]);
}
delete[] AfterTransformGd1Point;
delete[] AfterTransformGd2Point;
}
::SelectObject(m_hMemDC, m_hOldDrawPointPen);
double BeforeTransformLastGd[CNC_AXIS_NUM];
memcpy(BeforeTransformLastGd, m_GraphDataInfoStructDeque[m_iGraphPointCurrentNum - 1].nAxisRealPos, sizeof(double) * CNC_AXIS_NUM);
double* AfterTransformLastGd = TransformPoint(BeforeTransformLastGd);
DrawToolPoint(AfterTransformLastGd[0], AfterTransformLastGd[1]);
}
LeaveCriticalSection(&m_cs);
}
示例3: TransformPoint
FloatRect Transform::TransformRect(const FloatRect& rectangle) const
{
// Transform the 4 corners of the rectangle
const Vector2f points[] =
{
TransformPoint(rectangle.Left, rectangle.Top),
TransformPoint(rectangle.Left, rectangle.Top + rectangle.Height),
TransformPoint(rectangle.Left + rectangle.Width, rectangle.Top),
TransformPoint(rectangle.Left + rectangle.Width, rectangle.Top + rectangle.Height)
};
// Compute the bounding rectangle of the transformed points
float left = points[0].x;
float top = points[0].y;
float right = points[0].x;
float bottom = points[0].y;
for (int i = 1; i < 4; ++i)
{
if (points[i].x < left) left = points[i].x;
else if (points[i].x > right) right = points[i].x;
if (points[i].y < top) top = points[i].y;
else if (points[i].y > bottom) bottom = points[i].y;
}
return FloatRect(left, top, right - left, bottom - top);
}
示例4: GetNodeInCell
static std::pair<Float2, Float2> GetNodeInCell(const TerrainCell& cell, unsigned nodeIndex)
{
const auto& sourceNode = *cell._nodes[nodeIndex];
auto nodeMinInCell = Truncate(TransformPoint(sourceNode._localToCell, Float3(0.f, 0.f, 0.f)));
auto nodeMaxInCell = Truncate(TransformPoint(sourceNode._localToCell, Float3(1.f, 1.f, 1.f)));
return std::make_pair(nodeMinInCell, nodeMaxInCell);
}
示例5: ddRenderVecs
static void ddRenderVecs(const mat4& projview)
{
const ShaderInfo* shader = g_dbgdrawShader.get();
GLint posLoc = shader->m_attrs[GEOM_Pos];
GLint colorLoc = shader->m_attrs[GEOM_Color];
GLint mvpLoc = shader->m_uniforms[BIND_Mvp];
glUniformMatrix4fv(mvpLoc, 1, 0, projview.m);
const ddVec* cur = g_lists.m_vecs;
if(cur)
{
glBegin(GL_LINES);
while(cur)
{
vec3 from = TransformPoint(cur->m_xfm, cur->m_from);
vec3 to = TransformPoint(cur->m_xfm, cur->m_from + cur->m_vec);
glVertexAttrib3fv(colorLoc, &cur->m_color.r);
glVertexAttrib3fv(posLoc, &from.x);
glVertexAttrib3fv(posLoc, &to.x);
cur = cur->m_next;
}
glEnd();
}
}
示例6: TransformPoint
float SSVTreeCollider::LssPssDist(float r0, const Point& point0, const Point& point1, float r1, const Point& center0)
{
Point p0, p1;
TransformPoint(p0, point0, mR0to1, mT0to1);
TransformPoint(p1, point1, mR0to1, mT0to1);
float d = PointSegDist(center0, p0, p1);
return d - r0 - r1;
}
示例7: TransformPoint
/** Draws the eyebrow onto Head Top
* \param p1 Point to start
* \param p2 Point to finish
* \param graphics Graphics context to draw on
*/
void CHeadTop::DrawEyebrow(Point p1, Point p2, Gdiplus::Graphics *graphics)
{
Gdiplus::Point start = TransformPoint(p1);
Gdiplus::Point finish = TransformPoint(p2);
Pen eyebrowPen(Color::Black, 2);
graphics->DrawLine(&eyebrowPen, start, finish);
}
示例8: RayVsAABB
bool RayVsAABB(const std::pair<Float3, Float3>& worldSpaceRay, const Float4x4& aabbToWorld, const Float3& mins, const Float3& maxs)
{
// Does this ray intersect the aabb?
// transform the ray back into aabb space, and do tests against the edge planes of the bounding box
auto worldToAabb = Inverse(aabbToWorld); // maybe not be orthonormal input. This is used for terrain, which has scale on aabbToWorld
auto ray = std::make_pair(
TransformPoint(worldToAabb, worldSpaceRay.first),
TransformPoint(worldToAabb, worldSpaceRay.second));
return RayVsAABB(ray, mins, maxs);
}
示例9: TransformPoint
EDMath::Sphere SphereCollider::GetWorldSphere(void)
{
Sphere s;
s.radius = sphere.radius;
TransformPoint( s.center, sphere.center, GetGameObject()->GetTransform()->GetWorldMatrix() );
return s;
}
示例10: SolveEquations
/**************************************************************************//**
* @author Caitlin Taggart
*
* @par Description:
* Generates the fractal by solving the equations and goes through the first
* couple transformed points.
*****************************************************************************/
void GenWindow::GenerateFractal(vector<vector<double> > transforms, vector<Point> p, double c[])
{
//get the transfroms
SolveEquations(transforms);
//copy the data needed
points = p;
for (int i = 0; i < 3; i++)
{
color[i] = c[i];
}
//initialize the transforms
idle.x = 0;
idle.y = 0;
//generate the first few tranformed points
for (int i = 0; i < 16; i++)
{
int random = rand() % Transforms.size();
idle = TransformPoint(idle, Transforms[random]);
}
//let the idle function know it can generate
generate = true;
//tell glut that it should redisplay points
glutSetWindow(_windowID);
glutPostRedisplay();
}
示例11: rand
/**************************************************************************//**
* @author Caitlin Taggart
*
* @par Description:
* This is the idle call back function. This generates the points that create
* the fractal and then calls redisplay. Does this ten points at a time. Once
* this function is called and worked on for more than 100000 points it stops.
*****************************************************************************/
void GenWindow::Idle()
{
static int j = 0;
if (generate && j < 100000)
{
for (int i = 0; i < 10; i++)
{
//find a random transform
int random = rand() % Transforms.size();
//transform the last point
idle = TransformPoint(idle, Transforms[random]);
//add a color based on the transform
idle.r = Transforms[random].red;
idle.g = Transforms[random].green;
idle.b = Transforms[random].blue;
//add it to the generated points list
genPoints.push_back(idle);
j++;
}
//ask glut to redisplay
glutSetWindow(_windowID);
glutPostRedisplay();
}
}
示例12:
void mlMatrix3x4::TransformPoints(mlVector3D *out, const mlVector3D *in, int numPt) const
{
for (int i = 0; i < numPt; i++)
{
*out++ = TransformPoint(*in++);
}
}
示例13: TransformPoint
void JRTMesh::Transform(const Matrix4f& rXForm, const Matrix4f& rInverse)
{
// transform positions
for (UINT i = 0; i < m_nVertexCount; i++)
{
TransformPoint(&m_Positions[i], &rXForm, &m_Positions[i]);
}
Matrix4f inverseTranspose = rInverse.Transpose();
// transform normals
if (! m_Normals.empty ())
{
for (UINT i = 0; i < m_nVertexCount; i++)
{
ALIGN16 Vec3f tmp = m_Normals[i];
TransformVector(&tmp, &inverseTranspose, &m_Normals[i]);
m_Normals[i] = Normalize(m_Normals[i]);
}
}
else
{
// transform face normals
for (UINT i = 0; i < m_nTriangleCount; i++)
{
ALIGN16 Vec3f tmp = m_FaceNormals[i];
TransformVector(&tmp, &inverseTranspose, &m_FaceNormals[i]);
m_FaceNormals[i] = tmp;
}
}
}
示例14: cairo_save
bool
Image::InsideObject (cairo_t *cr, double x, double y)
{
if (!FrameworkElement::InsideObject (cr, x, y))
return false;
cairo_save (cr);
cairo_new_path (cr);
cairo_set_matrix (cr, &absolute_xform);
double nx = x;
double ny = y;
TransformPoint (&nx, &ny);
Render (cr, NULL, true);
bool inside = cairo_in_fill (cr, nx, ny);
cairo_restore (cr);
if (inside)
inside = InsideLayoutClip (x, y);
if (inside)
inside = InsideClip (cr, x, y);
return inside;
}
示例15: TransformBoundingBox
std::pair<Float3, Float3> TransformBoundingBox(const Float3x4& transformation, std::pair<Float3, Float3> boundingBox)
{
Float3 corners[] =
{
Float3( boundingBox.first[0], boundingBox.first[1], boundingBox.first[2] ),
Float3( boundingBox.second[0], boundingBox.first[1], boundingBox.first[2] ),
Float3( boundingBox.first[0], boundingBox.second[1], boundingBox.first[2] ),
Float3( boundingBox.second[0], boundingBox.second[1], boundingBox.first[2] ),
Float3( boundingBox.first[0], boundingBox.first[1], boundingBox.second[2] ),
Float3( boundingBox.second[0], boundingBox.first[1], boundingBox.second[2] ),
Float3( boundingBox.first[0], boundingBox.second[1], boundingBox.second[2] ),
Float3( boundingBox.second[0], boundingBox.second[1], boundingBox.second[2] )
};
for (unsigned c=0; c<dimof(corners); ++c) {
corners[c] = TransformPoint(transformation, corners[c]);
}
Float3 mins(FLT_MAX, FLT_MAX, FLT_MAX), maxs(-FLT_MAX, -FLT_MAX, -FLT_MAX);
for (unsigned c=0; c<dimof(corners); ++c) {
mins[0] = std::min(mins[0], corners[c][0]);
mins[1] = std::min(mins[1], corners[c][1]);
mins[2] = std::min(mins[2], corners[c][2]);
maxs[0] = std::max(maxs[0], corners[c][0]);
maxs[1] = std::max(maxs[1], corners[c][1]);
maxs[2] = std::max(maxs[2], corners[c][2]);
}
return std::make_pair(mins, maxs);
}