Hello!
I'm trying to draw a sine wave with specified start point, end point and length. To do so I have already done finding Amplitude and Period for sine function.
The problem is that sine wave is not fitted into points (its below). Please take a look:
What I thought how to solve this:
1) Create two vectors. First vector is from starting to ending point and second vector is from starting wave point to ending wave point
2) Calculate angle between them
3) Try to rotate the sine wave with computed angle
4) Add y offset in order to fit sine wave between points (see output image)
But...There is a problem, the sine is not rotated in desired angle as You can see in this image (the blurred waves are made in graphic app)
**What is the problem?**
Data:
objectStart = {-0.6061,0.2351}
objectEnd = {-0.1999,0.1787}
found sine = {y= 0.1 * sin( 24.85 * x)+0 foundLen=0.78}
curveStart = {-0.6061,-0.0601}
curveEnd = {-0.1999,0.0967}
v1 = {0.4061,-0.0563}
v2 = {0.4061,0.1569}
angleBetweenVectors = 29.027
angleBetweenLineAndCurvePoints = -90.0
Code with comments:
http://pastebin.com/gxTftAB9
Thanks for any help!
Regards!
I'm trying to draw a sine wave with specified start point, end point and length. To do so I have already done finding Amplitude and Period for sine function.
The problem is that sine wave is not fitted into points (its below). Please take a look:

What I thought how to solve this:
1) Create two vectors. First vector is from starting to ending point and second vector is from starting wave point to ending wave point
2) Calculate angle between them
3) Try to rotate the sine wave with computed angle
4) Add y offset in order to fit sine wave between points (see output image)
But...There is a problem, the sine is not rotated in desired angle as You can see in this image (the blurred waves are made in graphic app)

**What is the problem?**
Data:
objectStart = {-0.6061,0.2351}
objectEnd = {-0.1999,0.1787}
found sine = {y= 0.1 * sin( 24.85 * x)+0 foundLen=0.78}
curveStart = {-0.6061,-0.0601}
curveEnd = {-0.1999,0.0967}
v1 = {0.4061,-0.0563}
v2 = {0.4061,0.1569}
angleBetweenVectors = 29.027
angleBetweenLineAndCurvePoints = -90.0
Code with comments:
http://pastebin.com/gxTftAB9
Thanks for any help!
Regards!