Skip to content

Improve arm IK code#112

Open
FirEmerald wants to merge 3 commits intoCrementif:mainfrom
FirEmerald:firemerald/improve-arm-ik
Open

Improve arm IK code#112
FirEmerald wants to merge 3 commits intoCrementif:mainfrom
FirEmerald:firemerald/improve-arm-ik

Conversation

@FirEmerald
Copy link
Contributor

Remove redundant calls to acos and cos by using the calculated cosine value directly
Remove call to sin by calculating the sine from the cosine directly
Back-propagate arm inversion fix into poleDir to correct the IK code

remove a redundant acos() call in SolveTwoBoneIK
calculate sinAlpha directly from cosAlpha
propagate negations all the way back into poleDir
negate sinAlpha to counteract
@Crementif
Copy link
Owner

Crementif commented Jan 31, 2026

Nice, nice to see a separate PR for this. Do you have any before and after screenshots, because I'm wondering if there's any visual differences. The readability fixes are nice, but readability is more important then saving a tiny fraction of CPU cycles and I don't want to encourage people to potentially breaking changes over it.

@FirEmerald
Copy link
Contributor Author

There's no visual differences. It just replaces three costly trig calls with a single, less costly sqrt call, and makes the code a bit cleaner by adjusting how the pole vector is represented rather than manually inverting the bone rotation axis.

@Crementif Crementif closed this Feb 7, 2026
@Crementif Crementif reopened this Feb 7, 2026
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