我正在编程一个物理模拟,并且模拟系统的每个元素都描述为存储在三个中的三维(x,y,z)long double.好吧,我的精确度非常精确,我想模拟足够庞大的系统,比如太阳系.考虑到太阳位于中心,我可以进一步保持精度高于或等于毫米,我应该使用哪个测量单位?
PS:
我知道太阳系远远超过太阳 - 冥王星的距离,但是这个距离是我想在模拟中认为有效的最小尺寸
例如我有这样的课程:
class example{
public:
int beauty;
void CompareObject(const example& another_object, example*& ptr);
};
Run Code Online (Sandbox Code Playgroud)
CompareObject() 方法将此对象与对象 another_object 进行比较(通过引用),并将最漂亮的对象的地址保存在指针 ptr 中(也是通过引用传递)
问题出在 CompareExampleObject 中:
void CompareExampleObject (const example& another_object, example*& ptr){
// set the best object
if(beauty < another_object.beauty)
ptr = &another_object;
else
ptr = // !!! What should I write here?
}
Run Code Online (Sandbox Code Playgroud)