Skip to content
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

Shape properties using VolumeProperties and VolumePropertiesGK #1290

Open
markkulait opened this issue Dec 4, 2023 · 4 comments
Open

Shape properties using VolumeProperties and VolumePropertiesGK #1290

markkulait opened this issue Dec 4, 2023 · 4 comments

Comments

@markkulait
Copy link

markkulait commented Dec 4, 2023

There are two different functions to calculate the volume properties in the BRepGProp (GProp_GProps, GProp_PrincipalProps) class:

  • VolumeProperties
  • VolumePropertiesGK

Both calculate the shape volume correctly. However, when calculating the inertia properties of the system, it seems that the former produces the correct results but the latter does not.
For a box and a cylinder:
Principal moments of inertia
Cylinder
Volume: 196349.54084936203
Ixx, Iyy, Izz: (194317337.4428578, 194291128.82151097, 61359231.51543226)
Cylinder GK
Volume: 196349.5408493644
Ixx, Iyy, Izz: (6.122366410532748e-40, -2.2351741790771484e-07, -3.5762786865234375e-07)
Box
Volume: 124999.99999999999
Ixx, Iyy, Izz: (52083333.33333338, 52083333.33333331, 52083333.333333276)
Box GK
Volume: 124999.99999999999
Ixx, Iyy, Izz: (1.6326310428087332e-40, -8.940696716308594e-08, -8.940696716308594e-08)

@tpaviot
Copy link
Owner

tpaviot commented Dec 4, 2023

see https://dev.opencascade.org/content/difference-between-brepgpropvolumeproperties-and-brepgpropvolumepropertiesgk

Both methods use different algorithms. GK means Gauss-Kronrod integration. To be rigourous, each algorithm results should be compared to the theoretical solution for volume/Ixx/Iyy/Izz.

@markkulait
Copy link
Author

For a cylinder (r = 25, h = 100), Izz = 0.5mr^2, and m = Pir^2h (density = 1).
This gives Izz = 61359231.5154 which is the same as the result given by the VolumeProperties function. The result given by the VolumePropertiesGK function is way off, probably it gives something close to zero.

@tpaviot
Copy link
Owner

tpaviot commented Dec 4, 2023

>>> print(brepgprop.VolumePropertiesGK.__doc__)


        Parameters
        ----------
        S: TopoDS_Shape
        VProps: GProp_GProps
        Eps: float (optional, default to 0.001)
        OnlyClosed: bool (optional, default to Standard_False)
        IsUseSpan: bool (optional, default to Standard_False)
        CGFlag: bool (optional, default to Standard_False)
        IFlag: bool (optional, default to Standard_False)
        SkipShared: bool (optional, default to Standard_False)

        Return
        -------
        float

Did you try to tune the parameters for this function?

@markkulait
Copy link
Author

No, both algorithms were run with eps = 1e-3 and OnlyClosed = True.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants