Math Is Fun Forum
  Discussion about math, puzzles, games and fun.   Useful symbols: ÷ × ½ √ ∞ ≠ ≤ ≥ ≈ ⇒ ± ∈ Δ θ ∴ ∑ ∫ • π ƒ -¹ ² ³ °

You are not logged in.

#1 2006-01-19 01:17:22

Paul
Member
Registered: 2006-01-19
Posts: 4

Plots on a curve

Hi

I am writing a computer progrom which plots a curve

I want to be able to input the start screen co-ordinated and the destination co-ordinates.

So for example. I may wish to start at 100,100 on the screen and end at 150,150. I want to plot a sine curve between these 2 points.

The formula I use to plot a sine curve is

x=x+1;
y=y-sin(degrees)*radius;

The - is required here for the program I am using

The question I have is is it possible to create a formula which plots a sine curve which hits 2 given points.

Offline

#2 2006-01-19 09:29:05

MathsIsFun
Administrator
Registered: 2005-01-21
Posts: 7,552

Re: Plots on a curve

The y-range for sin(x) is -1 to +1, so just scale it to suit.

yplot = 125 + sin(x)*25

Note: 125 = half-way between 100 and 150 = (100+150)/2

For the x-scale, it depends on you I suppose, but you could start with:

xplot = 125 + x*(25/360)

This will give x-values from -360 to +360, with x=0 at the center of the graph

If you want the sine to start at the lower left corner and go to the upper-right corner, then try:

xplot = 125 + x*(25/90)


"The physicists defer only to mathematicians, and the mathematicians defer only to God ..."  - Leon M. Lederman

Offline

Board footer

Powered by FluxBB