Skip to content

Commit

Permalink
atan2
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Jul 21, 2018
1 parent 1ed6fde commit fb7ed99
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/main/java/net/aufdemrand/denizencore/objects/Element.java
Original file line number Diff line number Diff line change
Expand Up @@ -2173,6 +2173,31 @@ public dObject run(Attribute attribute, dObject object) {
}
});

// <--[tag]
// @attribute <el@element.atan2[<#.#>]>
// @returns Element(Decimal)
// @group math
// @description
// Interprets the element to be a Y value and the input value to be an X value (meaning: <Y.atan2[X]>),
// and returns an angle representing the vector of (X,Y).
// -->
registerTag("atan2", new TagRunnable.ObjectForm() {
@Override
public dObject run(Attribute attribute, dObject object) {
if (!attribute.hasContext(1)) {
dB.echoError("The tag el@element.atan2[...] must have a value.");
return null;
}
Element ele = (Element) object;
if (!ele.isDouble()) {
dB.echoError("Element '" + ele + "' is not a valid decimal number!");
return null;
}
return new Element(Math.atan2(ele.asDouble(), attribute.getDoubleContext(1)))
.getObjectAttribute(attribute.fulfill(1));
}
});

// <--[tag]
// @attribute <el@element.round_to[<#>]>
// @returns Element(Decimal)
Expand Down

0 comments on commit fb7ed99

Please sign in to comment.