Log#
Math / Arithmetic / Log
Can Read
Cannot Write
Description#
Returns the logarithm of a specified number in a specified base
Code#
using System;
using UnityEngine;
using VisualScript.Icons;
namespace VisualScript.Runtime
{
[Get]
[Title("Log")]
[Category("Math/Arithmetic/Log")]
[Description("Returns the logarithm of a specified number in a specified base")]
[Image(typeof(IconLog), ColorTheme.Type.Yellow)]
[Keywords("Base", "Logarithm")]
[Serializable]
public class TypeNumberMathLog : TypeNumber
{
[SerializeField] private GetNumber m_Number = new GetNumber();
[SerializeField] private GetNumber m_Base = new GetNumber();
public override double GetPreview(GameObject source) => Math.Log(this.m_Number.GetPreview(source), this.m_Base.GetPreview(source));
public override double Get(Args args)
{
double number = this.m_Number.Get(args);
double logBase = this.m_Base.Get(args);
return Math.Log(number, logBase);
}
public override string ToString()
{
return $"Log({this.m_Number}, {this.m_Base})";
}
protected override SubscriptionMode Subscription => SubscriptionMode.OnChange;
}
}