public static void Load(Script script) { ScriptTable Table = script.CreateTable(); Table.SetValue("PI", script.CreateDouble(PI)); Table.SetValue("Deg2Rad", script.CreateDouble(Deg2Rad)); Table.SetValue("Rad2Deg", script.CreateDouble(Rad2Deg)); Table.SetValue("Epsilon", script.CreateDouble(Epsilon)); Table.SetValue("min", script.CreateFunction(new min())); Table.SetValue("max", script.CreateFunction(new max())); Table.SetValue("abs", script.CreateFunction(new abs())); Table.SetValue("floor", script.CreateFunction(new floor())); Table.SetValue("clamp", script.CreateFunction(new clamp())); Table.SetValue("sqrt", script.CreateFunction(new sqrt())); Table.SetValue("pow", script.CreateFunction(new pow())); script.SetObjectInternal("math", Table); }
public ScriptNumber Pow(ScriptNumber value) //取几次方 { return(Script.CreateDouble(Math.Pow(ToDouble(), value.ToDouble()))); }
public abstract ScriptNumber Clamp(ScriptNumber min, ScriptNumber max); //取值的区间 public ScriptNumber Sqrt() //取平方根 { return(Script.CreateDouble(Math.Sqrt(ToDouble()))); }