Drawing a fitted wave sine between any two points in 2d

Luk4

New member
Joined
Oct 2, 2013
Messages
5
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: input.jpg


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) output.jpg


**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!
 
What are the meanings of the variously-colored lines on your graphs? Do they relate to your data and your efforts? If so, how? Thank you! ;)
 
What are the meanings of the variously-colored lines on your graphs? Do they relate to your data and your efforts? If so, how? Thank you! ;)

Hello!
Thanks for the answer! I have described in my code (see above for the link). But here You go:

- green lines are vectors (first vector is from my desired startpoint to endpoint, second vector is from sine starting point to her ending point)
- dark blue sine is rotated by angle between vectors (about 30 deg)
- dark violet is a result of found sine function
- blurred violet are transformed in graphic application just to show what i have to do

Here is a good news:

I have found how to fit my sine curve. I have done it by adding delta y between those two vectors into the value of found sine function (blue). However, the sine wave which is now fitted between points is a little bit different (violet). I got a question for all you experts, does it affect the length of sine wave which i found or the length of the original and "moved" curves are the same? Here is the image

krzywe_dopasowane.jpg
 
Top