public void RecalcPrimaryDependant(Canguro.View.GraphicView activeView, PointMagnet primaryPoint, LineMagnet[] globalAxes)
{
if (primaryPoint != null)
{
// Move area to lay on the primaryPoint and to set its direction any canonic
// plane (X=x, Y=y or Z=z) which is the most paralell to the screen plane
position = primaryPoint.Position;
// Get screen plane normal
Vector3 s0 = screenNormal[0], s1 = screenNormal[1], sNormal;
activeView.Unproject(ref s0);
activeView.Unproject(ref s1);
sNormal = s0 - s1;
// Assign the area normal to the most paralell canonical plane
// (giving priority to the Z plane)
int maxCosIndex = 2;
float cosX, cosY, cosZ;
cosX = Vector3.Dot(sNormal, globalAxes[0].Direction);
cosY = Vector3.Dot(sNormal, globalAxes[1].Direction);
cosZ = Vector3.Dot(sNormal, globalAxes[2].Direction);
if (Math.Abs(cosZ) < minZPlaneAngle)
maxCosIndex = (cosX >= cosY) ? ((cosX > cosZ) ? 0 : 2) : ((cosY > cosZ) ? 1 : 2);
normal = globalAxes[maxCosIndex].Direction;
}
else
{
position = Vector3.Empty;
normal = globalAxes[2].Direction;
}
}