maoruibin / maoruibin/maoruibin.github.com
根据横坐标计算贝塞尔曲线纵坐标
Open
Nobody has claimed this yet.
trick
utils
View
- Dominant language
- HTML
- Stars
- 22
- Forks
- 4
- PR merge metrics
- No merged PRs in 30d
Description
private float getBezierY(ArrayList<PointF> points, float x) {
float targetY = 0;
float moveX;
float mCurrentPosX;
float mCurrentPosY;
float mNextPosX;
float mNextPosY;
try {
if (points != null && points.size() > 0) {
if (x < points.get(0).x) {
targetY = points.get(0).y;
} else if (x > points.get(points.size() - 1).x) {
targetY = points.get(points.size() - 1).y;
} else {
for (int i = 0; i < points.size() - 1; i++) {
mCurrentPosX = points.get(i).x;
mCurrentPosY = points.get(i).y;
mNextPosX = points.get(i + 1).x;
mNextPosY = points.get(i + 1).y;
if (x <= mNextPosX && x >= mCurrentPosX) {
if (mNextPosY != mCurrentPosY) {
moveX = (x - mCurrentPosX) / (mNextPosX - mCurrentPosX);
targetY = (float) (mCurrentPosY * Math.pow((1f - moveX), 3) + 3 * mCurrentPosY * moveX * Math.pow(1f - moveX, 2)
+ 3 * mNextPosY * (1f - moveX) * Math.pow(moveX, 2) + mNextPosY * Math.pow(moveX, 3));
break;
} else {
targetY = mCurrentPosY;
break;
}
}
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
return targetY;
}
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue only provides a Java getBezierY method and does not name a repository file or test. First clarify the intended Bézier inputs, expected output, and requested change, then locate where this method belongs. Done should include a defined result for the stated x-coordinate cases and verification against agreed examples.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- web-dev
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100