Power#
Math / Arithmetic / Power
Can Read
Cannot Write
Description#
Returns the number elevated to the power of another number
Code#
using System;
using UnityEngine;
using VisualScript.Icons;
namespace VisualScript.Runtime
{
[Get]
[Title("Power")]
[Category("Math/Arithmetic/Power")]
[Description("Returns the number elevated to the power of another number")]
[Image(typeof(IconPowerCircle), ColorTheme.Type.Yellow)]
[Keywords("Pow", "Elevate", "Multiply", "Product", "Exponent")]
[Serializable]
public class TypeNumberMathPow : TypeNumber
{
[SerializeField] private GetNumber m_Number = new GetNumber();
[SerializeField] private GetNumber m_Power = new GetNumber();
public override double GetPreview(GameObject source) => Math.Pow(this.m_Number.GetPreview(source), this.m_Power.GetPreview(source));
public override double Get(Args args)
{
double number = this.m_Number.Get(args);
double power = this.m_Power.Get(args);
return Math.Pow(number, power);
}
public override string ToString()
{
return $"Power({this.m_Number}, {this.m_Power})";
}
protected override SubscriptionMode Subscription => SubscriptionMode.OnChange;
}
}