Action #2473

Reduce calls to std::acos in model evaluations

Added by Cardenzana Josh over 6 years ago.

Status:NewStart date:04/27/2018
Priority:NormalDue date:
Assigned To:Cardenzana Josh% Done:

0%

Category:-
Target version:-
Duration:

Description

There are many calls to std::acos that are done when computing the offset angle for various spatial models, specifically for the radial models where:

offset = \arccos{\theta}

std::acos is fairly computationally intensive, and unnecessary for models like GModelSpatialRadialDisk and GModelSpatialRadialShell. These can be simplified to use the cosine of the offset (or theta in the above equation), thus avoiding computing the arccosine.

GModelSpatialRadialDisk:
The model simply compares the offset value to the radius and returns the value if the offset < radius. Instead, the cosine of the distance can be compared to the cosine of the radius. This is similar to the method used in issue #2309 to speedup ctskymap.

GModelSpatialRadialShell:
This method uses the sine of the offset. There’s a relation for this that could speed things up:

\sin{(\arccos{\theta})} = \sqrt{1-\theta^2}


Recurrence

No recurrence.

Also available in: Atom PDF