转载自https://blog.csdn.net/w565066157/article/details/80847227
需要利用OSG的库
osg::Vec3 firstPoint = points->at(0); osg::Vec3 secondPoint = points->at(1); osg::Vec3 thirdPoint = points->at(2); osg::Vec3 ac = thirdPoint - firstPoint; osg::Vec3 ab = secondPoint - firstPoint; // 判断是否三点共线 osg::Vec3 ac2 = thirdPoint - firstPoint; osg::Vec3 ab2 = secondPoint - firstPoint; ac2.normalize(); ab2.normalize(); if (ac2 == ab2) { return false; } osg::Vec3 abXac = ab ^ ac; osg::Vec3 abXacXab = abXac ^ ab; osg::Vec3 acXabXac = ac ^ abXac; osg::Vec3 toCircumsphereCenter = (abXacXab * ac.length2() + acXabXac * ab.length2()) / (2.f * abXac.length2()); float circumsphereRadius = toCircumsphereCenter.length(); osg::Vec3 CircumsphereCenter = firstPoint + toCircumsphereCenter; --------------------- 作者:书灵伯爵 来源:CSDN 原文:https://blog.csdn.net/w565066157/article/details/80847227 版权声明:本文为博主原创文章,转载请附上博文链接!