Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add solveOrderedRealCubic #177

Open
wants to merge 5 commits into
base: version2
Choose a base branch
from
Open

Add solveOrderedRealCubic #177

wants to merge 5 commits into from

Conversation

ecurtiss
Copy link
Contributor

@ecurtiss ecurtiss commented Nov 29, 2020

I didn't realize I have to use spaces. I've never made a pull request before so I don't know how to change it.

Copy link
Owner

@Quenty Quenty left a comment

Choose a reason for hiding this comment

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

looks good to me, asking trey

Quenty
Quenty previously approved these changes Dec 21, 2020
Copy link
Owner

@Quenty Quenty left a comment

Choose a reason for hiding this comment

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

Looks good overall. I don't think you have merge permissions, so I'll just merge this, and you can put in another PR to fix the sorting if you want.

local z2 = coeff * math.cos(theta + math.pi / 6) - A/3
local solutions = table.create(3)
solutions[1], solutions[2], solutions[3] = z0, z1, z2
table.sort(solutions)
Copy link
Owner

Choose a reason for hiding this comment

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

nit: maybe just use if-statements here.

@ecurtiss
Copy link
Contributor Author

I'm pretty lost with this git stuff, but I think I the PR is correct now. Here are more details on what I changed

  1. Switched cubeRoot to a much faster version by fractality
  2. Quadratic calls Linear when a = 0
  3. Quadratic returns 2 roots when there's only 1 solution with multiplicity 2
  4. Cubic variables are named nicer
  5. Swapped out table.sort in cubic for if statements
  6. Assigned repeated calculations to variables in cubic

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.

2 participants