We help IT Professionals succeed at work.

Calculate TriangleWave

DelphiUK
DelphiUK asked
on
495 Views
Last Modified: 2012-06-16
Hi

How to calculate a bipolar trianglewave and save the values in an array?

Is must be posible to change amplitude and freqency.
Comment
Watch Question

Commented:
A triangle wave is just a special linear type of a sinusoidal wave.

Here you get the function to calculate a bipolar triangular wave...
How Do I Plot a Triangular Sine Wave?

Principle of storing points in a dynamic array...
Type
  TPointReal = record
     X: Real;
     Y: Real;
  end;

  TriangleWavePointArray = array of TPointReal;

var
  TriangleWavePoints: TriangleWavePointArray;


//initialze/clear array 
SetLength(TriangleWavePoints,0); 

//for each coordinate pair to add
SetLength(TriangleWavePoints,High(TriangleWavePoints)+1);  //add a point
TriangleWavePoints[High(TriangleWavePoints)].X:=..
TriangleWavePoints[High(TriangleWavePoints)].Y:=..

Open in new window


Now all you have to do is calculate X and Y values by implementing the triangle wave formula from above link...

Author

Commented:
I had try the above formula. And the problem is that if you change the freqency and amplitude then the height og the triangle Varies.
developmentguruPresident

Commented:
The amplitude IS the height on every graph I have seen.  I imagine that means you have some custom trait you want for your graph.  How would it show the amplitude without changing the height?  If you can explain this then we should be able to help you achieve the desired effect.

Author

Commented:
The problem is that if you use the following formula to draw a triangle wave (2/pi)*10*arcsin(sin(5x))   (amplitude: 10 - freqency: 5) you Will see that the amplitude varies over time. I need a triangle wave with a constant amplitude at all the time.
President
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:
Sorry for the waiting time I just want back from vacation.

developmentguru: U are right is was an illusion, the amplutide does not varying.
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.