Hi @yuuuuuming
welcome to the arduino-forum.
Well done to post a part of your sketch as a code-section.
You ALWAYS should post your complete sketch.
Especially as a beginner you might be not awareof that some lines of code far away from the place you were analysing can be important.
Here too:
one thing to check Your angle-index runs from 0 to 1001 which are in summary 1002
Did you define your array with 1002 elements?
This line of code is missing in your posting.
what library do you use that calls the functions
You are calling the exact same object with different parameters.
Does this library allow this?
Not analysable because this line of code is not in your code-snippet
not visible in the part of the code that you have posted
So please post your complete sketch from th every first to the very last line of code
You can post a complete sketch within 5 seconds like explained in this tutorial