Loading...
Processing Forum
Recent Topics
All Forums
Move this topic
Forum :
Share your Work
Programming Questions
Core Library Questions
Contributed Library Questions
Android Processing
Processing with Other Languages
Integration and Hardware
Library and Tool Development
Events and Opportunities
General Discussion
Sub forum :
Move this topic
Cancel
Programming Questions
knuppel
Sin(): only positive wave
in
Programming Questions
•
4 months ago
I tried this example:
http://processing.org/reference/sin_.html
How can only display the positive wave?
1
Replies(3)
PhiLho
Re: Sin(): only positive wave
4 months ago
Perhaps with the abs() function? Or constrain(), if you want another effect.
Leave a comment on PhiLho's reply
datguy
Re: Sin(): only positive wave
4 months ago
Is this what you want?
float a = PI;
float inc = TWO_PI/25.0;
for (int i = 0; i < 50; i=i+4) {
line(i, 50, i, 50+sin(a)*40.0);
a = a + inc;
}
Leave a comment on datguy's reply
PhiLho
Re: Sin(): only positive wave
4 months ago
float a = 0.0;
float inc = TWO_PI/25.0;
for (int i = 0; i < 100; i += 4) {
line(i, 50, i, 50 + sin(a) * 40.0);
a += inc;
}
=>
float a = 0.0;
float inc = TWO_PI/25.0;
for (int i = 0; i < 100; i += 4) {
line(i, 50, i, 50 - abs(sin(a)) * 40.0);
a += inc;
}
or
float a = 0.0;
float inc = TWO_PI/25.0;
for (int i = 0; i < 100; i += 4) {
line(i, 50, i, 50 - constrain(sin(a), 0, 1) * 40.0);
a += inc;
}
Leave a comment on PhiLho's reply
Change topic type
Topic Type :
Discussions
Questions
No of days :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
Change topic type
Cancel
Link this topic
Provide the permalink of a topic that is related to this topic
Permalink
Save
Close
Reply to knuppel's question
Top
Reply
{"z4085862":[25080000002248871,25080000002248951],"z21803537":[25080000002251486],"z27147509":[25080000002248889]}
Statistics
3
Replies
295
Views
0
Followers
Tags
No tags available for this topic.
Cancel
Actions
Permalink
Related Posts
Connecting lines to dots
How do I write a trig equation in p...
Search Multiple Strings for Words f...
How to optmize my code?
Trigonometry operation and precisio...