Function Question: (sqwv)

Discussion forum for G-Force users

Moderators: BTT, andy55, b.dwall, juxtiphi

Post Reply
User avatar
JayPro
Posts: 736
Joined: Sat May 01, 2004 10:51 pm
Location: Huntington Station, Long Island, New York

Function Question: (sqwv)

Post by JayPro »

What does this function do exactly??

Since I suck at mathematics in general, I could use some help extrapolating the subjectively perceived gibberish required to explain the concept to what I can actually see it doing.


Thanks.
"God is syntax."

jerohm
Senior Member
Posts: 400
Joined: Fri Jan 09, 2009 5:19 pm

Post by jerohm »

Code: Select all

Aspc=1             // so it is visible in frame
ConB=1

// sqwv(x) :
// return 1 if abs&#40;X&#41; <= 1.0, otherwise 0
//  or MORE ACCURATELY a square PULSE &#91;-1 ... 1&#93;

A0="&#40;2*s-1&#41;*2"         // &#91;-2 ... 2&#93;, inclusive

X0="A0"
Y0="sqwv&#40;A0&#41;/2"       // divided by 2 so it is visible in frame

Vers=500

Code: Select all

Aspc=1
ConB=1

// REAL&#40;static&#41; square wave

A0="&#40;2*s-1&#41;"    // &#91;-1 ... 1&#93;, inclusive
A1=10	        // Pulse Count
A2="A0*Pi * A1" // Cycles

X0="A0"
Y0="&#40;pos&#40;sign&#40;sin&#40;A2&#41;&#41;&#41; -.5&#41;/A1"	// centered about Y axis

Vers=500

Code: Select all

Aspc=1
ConB=1

// REAL&#40;moving&#41; square wave

A0="&#40;2*s-1&#41;"    // &#91;-1 ... 1&#93;, inclusive
A1=2 	        // Pulse Count
A2="A0*Pi * A1" // Cycles

X0="A0"
Y0="&#40;pos&#40;sign&#40;sin&#40;A2 - A1*t&#41;&#41;&#41; -.5&#41;/A1"	// centered about Y axis

Vers=500

are we good??

User avatar
ShohS
Posts: 41
Joined: Fri Apr 06, 2018 11:46 am
Location: no one must know shhhh

Post by ShohS »

I think its a square wave that doesn't loop
Nut

User avatar
DanPin
Posts: 161
Joined: Tue Mar 15, 2016 8:43 pm
Location: Los Angeles County, California

Post by DanPin »

ShohS wrote:I think its a square wave that doesn't loop
Well, you're absolutely right. The abbreviation 'sqwv' can mean 'square wave'. In the Documentation, under Config Programming | Logic/Discrete it technically explains "returns 1 if |x| <= 1.0 and 0 otherwise". This should make sense to you.

Post Reply