I draw my wave with this class:
package com.codobyte.display{
/*
@class: Sinus
@author: Cor van Dooren
@usage: Draw sinus dynamically
@syntax: var s:Sinus= new Sinus(params);
@params: positieX:int=0,
positieY:int=200,
lengte:int=200,
hoogte:int=200,
kleur:uint=0x000000,
lijndikte:int=2
@methods: s.startWave();
s.stopWave();
*/
import flash.display.*;
import flash.events.*;
public class Sinus extends Sprite {
private var positieX:int;
private var positieY:int;
private var hoogte:int;
private var lengte:int;
private var kleur:uint;
private var lijndikte:int;
private var val:int;
public function Sinus(positieX:int=0, positieY:int=200,
lengte:int=200, hoogte:int=200, kleur:uint=0x000000, lijndikte:int=2) {
this.positieX=positieX;
this.positieY= positieY;
this.lengte= lengte;
this.hoogte= hoogte;
this.kleur= kleur;
this.lijndikte=lijndikte;
val=0;
if (stage) {
init(null);
} else {
addEventListener(Event.ADDED_TO_STAGE, init,
false, 0, true);
}
}//end CONSTRUCTOR
private function init(e:Event):void {
removeEventListener(Event.ADDED_TO_STAGE, init);
graphics.lineStyle(lijndikte, kleur);
graphics.moveTo(positieX, positieY);
addEventListener(Event.REMOVED_FROM_STAGE, stopWave,
false,0,true);
}
public function startWave():void {
addEventListener(Event.ENTER_FRAME, enterframe,
false, 0, true);
}
public function stopWave():void {
removeEventListener(Event.ENTER_FRAME, enterframe);
removeEventListener(Event.REMOVED_FROM_STAGE,
stopWave);
}
private function enterframe(e:Event):void {
tekenSinus(val+=2);
}
private function tekenSinus(psdValue:int):void {
graphics.lineTo(positieX+psdValue+2,
positieY+hoogte*Math.sin(psdValue*360/lengte * Math.PI/180));
}
}
}
So how would I fit this in?
Reagrds,
Cor van Dooren
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Steve Abaffy
Sent: maandag 6 juni 2011 21:41
To: 'Flash Coders List'
Subject: RE: [Flashcoders] dynmically adding waves together problem
It would seem to me that you are drawing the two waves with some kind of
sine function.
Y1 = Sin(x1+Phase1)
Y2 = Sin(x2+Phase2)
So all you have do to create the third is
Y3 = Sin(x1+Phase1) + Sin(x2+Phase2)
Remember of course that Y3 will have a max/min of +2/-2 assuming of course
that originals are +1/-1 range as they should be with no amplitude
adjustment.
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Cor
Sent: Monday, June 06, 2011 2:16 PM
To: Flash Coders List
Subject: [Flashcoders] dynmically adding waves together problem
Hi All,
I need to draw waves dynamically which can be influenced at runtime.
These waves then have to add together and show the result in a third wave.
Here you can see the problem graphically:
http://www.codobyte.com/waves/
Every help is welcome!
TIA,
Cor van Dooren
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders