MCPcopy Create free account
hub / github.com/TheRealMJP/BakingLab / SGInnerProduct

Function SGInnerProduct

BakingLab/SG.h:33–39  ·  view source on GitHub ↗

Computes the inner product of two SG's, which is equal to Integrate(SGx(v) * SGy(v) * dv).

Source from the content-addressed store, hash-verified

31
32// Computes the inner product of two SG's, which is equal to Integrate(SGx(v) * SGy(v) * dv).
33inline Float3 SGInnerProduct(const SG& x, const SG& y)
34{
35 float umLength = Float3::Length(x.Sharpness * x.Axis + y.Sharpness * y.Axis);
36 Float3 expo = std::exp(umLength - x.Sharpness - y.Sharpness) * x.Amplitude * y.Amplitude;
37 float other = 1.0f - std::exp(-2.0f * umLength);
38 return (2.0f * Pi * expo * other) / umLength;
39}
40
41// Returns an approximation of the clamped cosine lobe represented as an SG
42inline SG CosineLobeSG(Float3 direction)

Callers 1

Calls 1

expFunction · 0.85

Tested by

no test coverage detected