📄 mgcdistpgm3pgm3.cpp
字号:
// Magic Software, Inc.
// http://www.magic-software.com
// Copyright (c) 2000, All Rights Reserved
//
// Source code from Magic Software is supplied under the terms of a license
// agreement and may not be copied or disclosed except in accordance with the
// terms of that agreement. The various license agreements may be found at
// the Magic Software web site. This file is subject to the license
//
// FREE SOURCE CODE
// http://www.magic-software.com/License/free.pdf
#include "MgcDistLin3Pgm3.h"
#include "MgcDistPgm3Pgm3.h"
//----------------------------------------------------------------------------MgcReal MgcSqrDistance (const MgcParallelogram3& rkPgm0,
const MgcParallelogram3& rkPgm1, MgcReal* pfPgm0P0, MgcReal* pfPgm0P1,
MgcReal* pfPgm1P0, MgcReal* pfPgm1P1)
{ MgcReal fS, fT, fS0, fT0; // pgm0 parameters MgcReal fU, fV, fU0, fV0; // pgm1 parameters MgcReal fSqrDist, fSqrDist0; MgcSegment3 kSeg; // compare edges of pgm0 against all of pgm1 kSeg.Origin() = rkPgm0.Origin(); kSeg.Direction() = rkPgm0.Edge0(); fSqrDist = MgcSqrDistance(kSeg,rkPgm1,&fS,&fU,&fV); fT = 0.0; kSeg.Direction() = rkPgm0.Edge1(); fSqrDist0 = MgcSqrDistance(kSeg,rkPgm1,&fT0,&fU0,&fV0); fS0 = 0.0; if ( fSqrDist0 < fSqrDist ) { fSqrDist = fSqrDist0; fS = fS0; fT = fT0; fU = fU0; fV = fV0; } kSeg.Origin() = rkPgm0.Origin() + rkPgm0.Edge0(); fSqrDist0 = MgcSqrDistance(kSeg,rkPgm1,&fT0,&fU0,&fV0); fS0 = 1.0; if ( fSqrDist0 < fSqrDist ) { fSqrDist = fSqrDist0; fS = fS0; fT = fT0; fU = fU0; fV = fV0; } kSeg.Origin() = rkPgm0.Origin() + rkPgm0.Edge1(); kSeg.Direction() = rkPgm0.Edge0(); fSqrDist0 = MgcSqrDistance(kSeg,rkPgm1,&fS0,&fU0,&fV0); fT0 = 1.0; if ( fSqrDist0 < fSqrDist ) { fSqrDist = fSqrDist0; fS = fS0; fT = fT0; fU = fU0; fV = fV0; } // compare edges of pgm1 against all of pgm0 kSeg.Origin() = rkPgm1.Origin(); kSeg.Direction() = rkPgm1.Edge0(); fSqrDist0 = MgcSqrDistance(kSeg,rkPgm0,&fU0,&fS0,&fT0); fV0 = 0.0; if ( fSqrDist0 < fSqrDist ) { fSqrDist = fSqrDist0; fS = fS0; fT = fT0; fU = fU0; fV = fV0; } kSeg.Direction() = rkPgm1.Edge1(); fSqrDist0 = MgcSqrDistance(kSeg,rkPgm0,&fV0,&fS0,&fT0); fU0 = 0.0; if ( fSqrDist0 < fSqrDist ) { fSqrDist = fSqrDist0; fS = fS0; fT = fT0; fU = fU0; fV = fV0; } kSeg.Origin() = rkPgm1.Origin() + rkPgm1.Edge0(); fSqrDist0 = MgcSqrDistance(kSeg,rkPgm0,&fV0,&fS0,&fT0); fU0 = 1.0; if ( fSqrDist0 < fSqrDist ) { fSqrDist = fSqrDist0; fS = fS0; fT = fT0; fU = fU0; fV = fV0; } kSeg.Origin() = rkPgm1.Origin() + rkPgm1.Edge1(); kSeg.Direction() = rkPgm1.Edge0(); fSqrDist0 = MgcSqrDistance(kSeg,rkPgm0,&fU0,&fS0,&fT0); fV0 = 1.0; if ( fSqrDist0 < fSqrDist ) { fSqrDist = fSqrDist0; fS = fS0; fT = fT0; fU = fU0; fV = fV0; }
if ( pfPgm0P0 )
*pfPgm0P0 = fS;
if ( pfPgm0P1 )
*pfPgm0P1 = fT;
if ( pfPgm1P0 )
*pfPgm1P0 = fU;
if ( pfPgm1P1 )
*pfPgm1P1 = fV;
return MgcMath::Abs(fSqrDist);
}//----------------------------------------------------------------------------MgcReal MgcDistance (const MgcParallelogram3& rkPgm0,
const MgcParallelogram3& rkPgm1, MgcReal* pfPgm0P0, MgcReal* pfPgm0P1,
MgcReal* pfPgm1P0, MgcReal* pfPgm1P1)
{
return MgcMath::Sqrt(MgcSqrDistance(rkPgm0,rkPgm1,pfPgm0P0,pfPgm0P1,
pfPgm1P0,pfPgm1P1));
}
//----------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -