-
Notifications
You must be signed in to change notification settings - Fork 114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use Vector3d instead of Vector3 #328
Conversation
by using vector3d instead of Vector3, the calculated distance is much more accurate, resulting in much less instability in the final solar power
@@ -155,10 +155,10 @@ public static Double Flux(ModularFlightIntegrator fi, KopernicusStar star) | |||
// Get sunVector | |||
RaycastHit raycastHit; | |||
Boolean directSunlight = false; | |||
Vector3d scaledSpace = ScaledSpace.LocalToScaledSpace(fi.IntegratorTransform.position); | |||
Vector3d scaledSpace = ScaledSpace.LocalToScaledSpace(fi.Vessel.CoMD); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is CoMD actually the same as the vessel position in world space? I am not entirely sure, and can't check it at the moment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it is, it gives the Vector3d position of the vessel, which is 64 bit instead 32 bit transform
Double scale = Math.Max((star.sun.scaledBody.transform.position - scaledSpace).magnitude, 1); | ||
Vector3 sunVector = (star.sun.scaledBody.transform.position - scaledSpace) / scale; | ||
Ray ray = new Ray(ScaledSpace.LocalToScaledSpace(fi.IntegratorTransform.position), sunVector); | ||
Vector3d sunVector = (star.sun.position - scaledSpace) / scale; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change would have serious implications on the calculation, because you are replacing a scaled space position with a local space one (scaled space = local space / 6000).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possibly, but perhaps we should only use scale space position when it is actually relevant, by default you realy don't need it. My gut feeling sais that if it is relevant, you are better of calculating it manually by multiplying COMD by the scale but I'm not sure. Either-way should aim for maximum precision at all times
by using vector3d instead of Vector3, the calculated distance is much more accurate, resulting in much less instability in the final solar power