本文整理汇总了C++中Coordinates::norm方法的典型用法代码示例。如果您正苦于以下问题:C++ Coordinates::norm方法的具体用法?C++ Coordinates::norm怎么用?C++ Coordinates::norm使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Coordinates
的用法示例。
在下文中一共展示了Coordinates::norm方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: unitVector
// Converts the vector to a unit vector
// USE ONLY ON VECTORS, NOT COORDINATES!
// Return Coordinates or void?
Coordinates unitVector( Coordinates& point )
{
if (abs(point.norm() - 1) < .00001)
{
return point;
}
float norm = point.norm();
Coordinates newPoint((point.x / norm),
(point.y / norm),
(point.y / norm));
return newPoint;
}
示例2: calculateAngleBetweenPlanes
// this calculates the angle between two planes. In this case,
// we take as arguments a precalculated set of coordinates for
// one plane (to reduce the number of computations), the second
// residue in question, and the index for the center that we
// are curious about
float calculateAngleBetweenPlanes( Coordinates& planeP,
AminoAcid& aa2,
int index2 )
{
Coordinates planeQ;
float normV;
float normP;
float dotProd;
float cosValue;
// get the plane equation for the center we are curious about
getPlaneEquation( *(aa2.center[index2].plane_info[ C__PLANE_COORD_AG]),
*(aa2.center[index2].plane_info[O_1_PLANE_COORD_AG]),
*(aa2.center[index2].plane_info[O_2_PLANE_COORD_AG]),
&planeQ);
// calculate the norms of these planes
normV = planeP.norm();
normP = planeQ.norm();
// and their dot product
dotProd = dotProduct( planeP,
planeQ );
// and use them to calculate the value of the cosine of the angle
cosValue = dotProd / ( normV * normP );
// error check
if( cosValue < -1 || cosValue > 1 )
{
cerr << red << "Error" << reset << ":Error: Cosine of angle, " << cosValue << ", lies outside of -1 and 1" << endl;
return 1000;
}
else
{
// and actually calculate the angle value
float angle = acos(cosValue) * 180 / 3.14159;
if(angle > 90)
{
angle = 180.0 - angle;
}
return angle;
}
}
示例3: angleBetweenPlaneAndLine
// Calculate the angle between a plane and a line
float angleBetweenPlaneAndLine ( Coordinates& plane,
Coordinates& point1,
Coordinates& point2 )
{
float normalv;
float normalp;
float dotProd;
float angle;
float cosValue;
Coordinates tempCoord;
// Calculate the norm of the plane coordinates
normalv = plane.norm();
// subtract the 2 points together and get their norm
tempCoord = point2 - point1;
normalp = tempCoord.norm();
// get the dot producted between the plane and difference of the points
dotProd = dotProduct(plane, tempCoord);
// Now we can get the cosine value with this information
cosValue = dotProd/(normalv * normalp);
// double check that we aren't doing anything illegal with arccos
if( cosValue < -1.0 || cosValue > 1.0 )
{
cerr << red << "Error" << reset << ":Error: Cosine of angle, " << cosValue << ", lies outside of -1 and 1" << endl;
angle = 1000;
}
else
{
// and actually calculate the angle
angle = abs ( 90 - ( acos(cosValue) * 180 / 3.14159 ) );
}
return angle;
}