本文整理汇总了C++中YsVec3::Normalize方法的典型用法代码示例。如果您正苦于以下问题:C++ YsVec3::Normalize方法的具体用法?C++ YsVec3::Normalize怎么用?C++ YsVec3::Normalize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类YsVec3
的用法示例。
在下文中一共展示了YsVec3::Normalize方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: collide
void Cylinder::collide(Particle &particle)const
{
YsVec3 r=particle.getPosition();
YsVec3 v=particle.getVelocity();
YsVec3 n;
//particle penetrates neither bottom nor radius
if (bottom_fun(r)<0 && side_fun(r)<0) {
return;
}
if (bottom_fun(r)>0) {
n=YsYVec();
if (n*v<0) {
v=v-2*(v*n)*n; //bounce velocity
particle.setVelocity(v);
}
}
if (side_fun(r)>0) {
n=origin-r;
n.SetY(0.0);
n.Normalize();
if (n*v<0) {
v=v-2*(v*n)*n; //bounce velocity
particle.setVelocity(v);
}
}
}
示例2: if
const YsVec3 YsTraceLineSegment::GetCurrentTangent(void) const
{
YsVec3 t;
if(curPos.seg<lSeg.GetN()-1)
{
t=lSeg[curPos.seg+1]-lSeg[curPos.seg];
t.Normalize();
return t;
}
else if(2<=lSeg.GetN())
{
t=lSeg[lSeg.GetN()-1]-lSeg[lSeg.GetN()-2];
t.Normalize();
return t;
}
return YsOrigin();
}
示例3: main
int main(int argc, char** argv)
{
InitYsClass();
axisOfOrbit.Set(1.0,1.0,1.0);
axisOfOrbit.Normalize();
orbiter=axisOfOrbit.GetArbitraryParpendicularVector();
orbiter.Normalize();
rot.Set(axisOfOrbit,0.0);
printf("Keys\n");
printf("A....Viewing Rotation Mode\n");
printf("B....Viewing Translation (Scroll) Mode\n");
printf("Z....Zoom\n");
printf("M....Mooz\n");
printf("----------\n");
eyeAtt.Set(YsPi/2.0,0.0,0.0);
eyeDistance=10.0;
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
glutInitWindowSize(500, 500);
glutInitWindowPosition(100, 100);
glutCreateWindow(argv[0]);
InitOpenGL();
glutDisplayFunc(Display);
glutReshapeFunc(Reshape);
glutKeyboardFunc(Keyboard);
glutMouseFunc(Mouse);
glutMotionFunc(Motion);
glutIdleFunc(Idle);
glutMainLoop();
return 0;
}
示例4:
void Ys3DDrawingEnvironment::TransformScreenCoordTo3DLine(YsVec3 &org,YsVec3 &vec,double sx,double sy) const
{
if(YSTRUE==screenOriginIsTopLeft)
{
sy=(double)windowHeight-sy;
}
const YsMatrix4x4 &viewMat=GetViewMatrix();
const YsMatrix4x4 &projMat=GetProjectionMatrix();
const YsMatrix4x4 projViewMat=projMat*viewMat;
const YsVec3 p1(sx,sy,-1.0),p2(sx,sy,1.0);
YsTransformScreenCoordTo3DCoord(org,p1,viewport,projViewMat);
YsTransformScreenCoordTo3DCoord(vec,p2,viewport,projViewMat);
vec-=org;
vec.Normalize();
}
示例5:
void YsCollisionOfPolygon::SetPolygon2(YSSIZE_T nv2,const YsVec3 v2[],const YsVec3 &nom2)
{
if(nv2>0)
{
np2=nv2;
p2=v2;
YsBoundingBoxMaker3 bbx;
bbx.Make(nv2,v2);
bbx.Get(p2min,p2max);
YsVec3 nom;
nom=nom2;
if(nom.IsNormalized()!=YSTRUE)
{
nom.Normalize();
}
pln2.Set(v2[0],nom);
}
}
示例6: DrawShell
void DrawShell(YsShell &shell,YsColor &col,YSBOOL inPolygon)
{
int i,j,k;
int nVtx,nPlg;
YsVec3 vtx[256];
if(inPolygon==YSTRUE)
{
glEnable(GL_LIGHTING);
}
else
{
glDisable(GL_LIGHTING);
}
nPlg=shell.GetNumPolygon();
for(i=0; i<nPlg; i++)
{
nVtx=shell.GetNumVertexOfPolygon(i);
if(nVtx>0)
{
double r,g,b;
YsVec3 nom;
shell.GetVertexListOfPolygon(vtx,256,i);
nom=(vtx[1]-vtx[0])^(vtx[2]-vtx[1]);
nom.Normalize();
col.GetDoubleRGB(r,g,b);
glColor3d(r,g,b);
if(inPolygon==YSFALSE || YsCheckConvex3(nVtx,vtx)==YSTRUE)
{
switch(inPolygon)
{
case YSFALSE:
glBegin(GL_LINE_LOOP);
break;
case YSTRUE:
glBegin(GL_POLYGON);
break;
}
glNormal3d(nom.x(),nom.y(),nom.z());
for(j=0; j<nVtx; j++)
{
glVertex3d(vtx[j].x(),vtx[j].y(),vtx[j].z());
}
glEnd();
}
else
{
YsSword swd;
swd.SetInitialPolygon(nVtx,vtx);
swd.Convexnize();
for(j=0; j<swd.GetNumPolygon(); j++)
{
nVtx=swd.GetNumVertexOfPolygon(j);
swd.GetVertexListOfPolygon(vtx,256,j);
glBegin(GL_POLYGON);
for(k=0; k<nVtx; k++)
{
glVertex3dv(vtx[k].GetValue());
}
glEnd();
}
}
}
}
}