本文整理汇总了C++中Point::CrossProduct方法的典型用法代码示例。如果您正苦于以下问题:C++ Point::CrossProduct方法的具体用法?C++ Point::CrossProduct怎么用?C++ Point::CrossProduct使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Point
的用法示例。
在下文中一共展示了Point::CrossProduct方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: IntersectionWith
//FIXME no equals check with == on double or float bring in an epsilon
bool Line::IntersectionWith(const Point &p1, const Point &p2) const {
Point AC = _point1 - p1;
Point DC = p2 - p1;
Point BA = _point2 - _point1;
double denominator = BA.CrossProduct(DC);
double numerator = DC.CrossProduct(AC);
if (denominator == 0.0) {
// the lines are superposed
if (numerator == 0.0) {
// the segment are superposed
return IsInLineSegment(p1) || IsInLineSegment(p2);
} else { // the lines are just parallel and do not share a common point
return false;
}
}
double r = numerator / denominator;
if (r < 0.0 || r > 1.0) {
return false;
}
double s = (BA.CrossProduct(AC)) / denominator;
if (s < 0.0 || s > 1.0) {
return false;
}
return true;
}
示例2: display
/*
* display
* a function to display the model
* Parameters:
* none
* Returns:
* none
*/
void display(void) {
if (stereo == 0){
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(vangle, 1.0, dnear, dfar);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(myCam.Eye.x, myCam.Eye.y, myCam.Eye.z, myCam.Rotate.x, myCam.Rotate.y, myCam.Rotate.z, myCam.ViewNorm.x, myCam.ViewNorm.y, myCam.ViewNorm.z);
glColor3f(red, green, blue);
myWorld.draw_world(); // draw all objects in the world
}else{
Point r;
GLdouble ratio, radians, wd2, ndfl;
GLdouble left1, right1,top1,bottom1,near1,far1;
near1 = 0.1;
far1 = 10000;
near1 = myCam.focalLength / 5;
/*Misc Stuff */
ratio = myCam.screenWidth / (GLdouble)myCam.screenHeight;
radians = DTOR * myCam.aperture / 2;
wd2 = near1 * tan(radians);
ndfl = near1 / myCam.focalLength;
r.CrossProduct(myCam.ViewVector, myCam.ViewNorm);
r.Normalize();
/* Derive the two eye positions */
r.x *= myCam.eyesep / 2.0;
r.y *= myCam.eyesep / 2.0;
r.z *= myCam.eyesep / 2.0;
r.printPoint();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
//left eye
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
left1 = - ratio * wd2 - 0.5 * myCam.eyesep * ndfl;
right1 = ratio * wd2 - 0.5 * myCam.eyesep * ndfl;
top1 = wd2;
bottom1 = - wd2;
glFrustum(left1,right1,bottom1,top1,near1,far1);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(myCam.Eye.x + r.x, myCam.Eye.y + r.y,myCam.Eye.z + r.z,
myCam.Rotate.x + r.x,
myCam.Rotate.y + r.y,
myCam.Rotate.z + r.z,
myCam.ViewNorm.x,myCam.ViewNorm.y,myCam.ViewNorm.z);
glColor3f(0.0, 0.0, 0.4);
glLineWidth(3.0);
glScalef(8.0, 8.0, 8.0);
myWorld.draw_world();
printf("LEft eye done\n");
//right eye
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
left1 = - ratio * wd2 + 0.5 * myCam.eyesep * ndfl;
right1 = ratio * wd2 + 0.5 * myCam.eyesep * ndfl;
top1 = wd2;
bottom1 = - wd2;
glFrustum(left1,right1,bottom1,top1,near1,far1);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(myCam.Eye.x - r.x,myCam.Eye.y - r.y,myCam.Eye.z - r.z,
myCam.Rotate.x - r.x,
myCam.Rotate.y - r.y,
myCam.Rotate.z - r.z,
myCam.ViewNorm.x,myCam.ViewNorm.y,myCam.ViewNorm.z);
glColor3f(0.4, 0.0, 0.0);
glScalef(8.0, 8.0, 8.0);
myWorld.draw_world();
}
glFlush();
glutSwapBuffers();
}