Skip to content
This repository has been archived by the owner on Apr 12, 2022. It is now read-only.

Commit

Permalink
location.normalized
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Jan 29, 2017
1 parent 98795a4 commit bdee8a9
Showing 1 changed file with 13 additions and 0 deletions.
Expand Up @@ -116,6 +116,19 @@ public UtilLocation getInternal() {
return new NumberTag(loc.x * loc.x + loc.y * loc.y + loc.z * loc.z);
});
// <--[tag]
// @Name LocationTag.normalized
// @Updated 2017/01/29
// @Group Mathematics
// @ReturnType LocationTag
// @Returns the normalized form of this vector location.
// @Example "0,2,0" .normalized returns "0,1,0".
// -->
handlers.put("normalized", (dat, obj) -> {
UtilLocation loc = ((LocationTag) obj).internal;
double len = 1.0 / Math.sqrt(loc.x * loc.x + loc.y * loc.y + loc.z * loc.z);
return new LocationTag(loc.x * len, loc.y * len, loc.z * len, loc.world);
});
// <--[tag]
// @Name LocationTag.world
// @Updated 2016/08/26
// @Group Identification
Expand Down

0 comments on commit bdee8a9

Please sign in to comment.