Skip to content

Use lua's math.atan2 for Math.atan2#765

Merged
Perryvw merged 13 commits intoTypeScriptToLua:masterfrom
hazzard993:math-atan2
Dec 18, 2019
Merged

Use lua's math.atan2 for Math.atan2#765
Perryvw merged 13 commits intoTypeScriptToLua:masterfrom
hazzard993:math-atan2

Conversation

@hazzard993
Copy link
Copy Markdown
Contributor

@hazzard993 hazzard993 commented Dec 8, 2019

Closes #746

Math.atan2 -> math.atan2 for all Lua targets

Edit: Except for Lua 5.3 which uses math.atan(y, x)

@Perryvw
Copy link
Copy Markdown
Member

Perryvw commented Dec 8, 2019

In case the target is Lua 5.3, we should use math.atan(y, x) since atan2 is deprecated, see https://www.lua.org/manual/5.3/manual.html#8.2


const expressionName = expression.name.text;

if (context.options.luaTarget === LuaTarget.Lua53 && expressionName === "atan2") {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer if you handle all atan2 cases in the same place (probably in its switch case)

@hazzard993 hazzard993 changed the title use lua's math.atan2 for Math.atan2 Use lua's math.atan2 for Math.atan2 Dec 13, 2019
case "atan":
case "atan2":
case "atan2": {
if (expressionName === "atan2" && context.options.luaTarget === LuaTarget.Lua53) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

expressionName === "atan2" is already checked by the switch, it's not required here

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I see why it's here now, it's still trange to me, you can move atan2 up to be the first case or something

hazzard993 and others added 2 commits December 17, 2019 12:11
Co-Authored-By: ark120202 <ark120202@gmail.com>
Co-Authored-By: ark120202 <ark120202@gmail.com>
@Perryvw Perryvw merged commit 10ff5f7 into TypeScriptToLua:master Dec 18, 2019
@hazzard993 hazzard993 deleted the math-atan2 branch December 20, 2019 05:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Transpiling Math.atan2 to math.atan2

3 participants