//
// Copyright © James South and contributors.
// Licensed under the Apache License, Version 2.0.
//
namespace ImageProcessor
{
using System;
///
/// Provides common mathematical methods.
///
internal static class ImageMaths
{
///
/// Gets the result of a sine cardinal function for the given value.
///
///
/// The value to calculate the result for.
///
///
/// The .
///
public static double SinC(double x)
{
const double Epsilon = .0001;
if (Math.Abs(x) > Epsilon)
{
x *= Math.PI;
return Clean(Math.Sin(x) / x);
}
return 1.0;
}
///
/// Ensures that any passed double is correctly rounded to zero
///
/// The value to clean.
///
/// The
/// .
private static double Clean(double x)
{
const double Epsilon = .0001;
if (Math.Abs(x) < Epsilon)
{
return 0.0;
}
return x;
}
}
}