Jump to content
Sign in to follow this  
graymachine

Drawing a Sine Curve in AI

Recommended Posts

Oh wait.. I get to say this for the first time...

 

This is SOO much easier in Cinema 4D. Just use a Formula spline and adjust the X & Y. Yay!

 

 

Edit... sorry, I think I mean "Spline" and not "Curve".

Edited by graymachine

Share this post


Link to post
Share on other sites
Guest dumbo

http://www.telegraphics.com.au/sw/info/sinehow.html

 

download the .ps file (which can be opened with illustrator)

 

and modify the code inside the .ps with bbedit or similar.

 

%!PS-Adobe
%%BoundingBox: 30 200 650 400

% Sine wave drawing by Toby Thain (mailto:toby@telegraphics.com.au)
% - straight line approximation
% - simplistic Bezier curve fitting
% both governed by "step" parameter (radians)

% Copyright (C) 2001-3 Toby Thain, toby@telegraphics.com.au
%
% This program is free software; you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by  
% the Free Software Foundation; either version 2 of the License, or
%  (at your option) any later version.
%
% This program is distributed in the hope that it will be useful,
%  but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
%  GNU General Public License for more details.
%
%  You should have received a copy of the GNU General Public License  
%  along with this program; if not, write to the Free Software
%  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

/pi 3.14159265 def
/step pi 4 div def % length of each line/curve segment; radians
/curvelength 7 def % curve length in radians

/r2d { 180 pi div mul } def % radians to degrees (approx)
/f { r2d sin } def % function to plot
/f' { r2d cos } def % first derivative

/drawpolygon {
 0 dup f moveto
 step dup curvelength {  % loop parameters for straight lines (radian units)
  dup f lineto
 } for
} def

/drawcurve {
 /third step 3 div def
0 dup f moveto
 0 step curvelength {  % loop parameters for Bezier approximation
   /x exch def
  x third add   x f x f' third mul add 
  x step third sub add   x step add dup f exch f' third mul sub 
   x step add   dup f  
   curveto
} for

} def

% transformation of unit sine wave - x radians, y -1..1
50 300 translate
80 80 scale

.1 setlinewidth
% drawpolygon .6 setgray stroke
drawcurve 0 setgray stroke

showpage

Share this post


Link to post
Share on other sites

I had to do the exact same thing yesteday. In the end I just created one cycle of the wave using the pen tool and snap to grid. Then copied this and connected the new cycles to the original one.

 

I'm not really an expert in either Illustrator or Cinema 4d, but I also was thinking that C4d seems to have a lot more useful tools for drawing splines than AI does.

Share this post


Link to post
Share on other sites
I'm not really an expert in either Illustrator or Cinema 4d, but I also was thinking that C4d seems to have a lot more useful tools for drawing splines than AI does.

 

It's true. Can't remember where but I saw a post once where a guy compared the spline editing functions between both and C4D bested Illustrator (save a few things).

Share this post


Link to post
Share on other sites

couldn't you just join two half circles in AI? Its not that hard. But - really, at this point why aren't there tools already incorporated in the damn program that can help with things like this? You could also try snapping to the grid, creating a linear spline and then rounding the corners effect at the proper radius. that might work. But really, joining two half circles seems faster and easier.

Share this post


Link to post
Share on other sites
Well, that may be true. The principle still holds true. A half circle is a good starting point - just adjust it to the profile of the wave. Duplicate. Move. Join it. Repeat.

 

Still, if you are manually adjusting the circle, you might as well just draw it.. which leads me back where we started :)

Share this post


Link to post
Share on other sites

what i do is, i draw a line with the the pen tool, making sure they have long bezier handles, but the line is still straight, by holding down the shift key, then I apply a roughen effect, with 0% roughen, but "n" points per inch, this is to subdivide the line. then with the white arrow I select every second point and drag them up or down, illustrator will have kept the beziers during subdivision and you get a sine-like line. not a perfect sine probably..

Edited by droon

Share this post


Link to post
Share on other sites

Half circles?!

Dear lord my high school physics teacher is screaming from his grave!

 

Does anybody remember that a sine wave is simply a 2D projection of a Helix?

And that a helix is simply a point that is being translated and rotated at a constant velocity?

 

SineMovie.png

(click image for movie)

 

-m

Share this post


Link to post
Share on other sites
I know this is an old thread, but if your talking about doing it in AI then you should make a straight line then Effects>Distort>Zig Zag>Smooth.
Winner

 

Not quite. Not as bad as the suggestion of making a sin curve out of half circles, but it is still some way off (the peaks are too rounded) - just try a zigzag effect against a real sin wave.

 

What I would like to know is whether you can get a mathematically accurate sine wave with a bezier curve, or whether it is just an approximation. (you can actually get pretty close with points at 90 deg, 270 deg, 450 deg etc)

Share this post


Link to post
Share on other sites
Not quite. Not as bad as the suggestion of making a sin curve out of half circles, but it is still some way off (the peaks are too rounded) - just try a zigzag effect against a real sin wave.

 

What I would like to know is whether you can get a mathematically accurate sine wave with a bezier curve, or whether it is just an approximation. (you can actually get pretty close with points at 90 deg, 270 deg, 450 deg etc)

 

Yeah, it's not quite ready for the Department of Weights and Measures. I deemed it "close enough".

 

Silver Medal.

Share this post


Link to post
Share on other sites
Yeah, it's not quite ready for the Department of Weights and Measures. I deemed it "close enough".

 

Silver Medal.

 

 

I guess it depends on your use. I changed the ZigZag to relative and expanded the appearance, then worked the scaling a little and got it really close. If it's just going to be a graphic element, I doubt anyone would call you on it. :)

Share this post


Link to post
Share on other sites

I found an easy solution for drawing a sine curve in AI!!

 

Go to the free mathematics software at http://www.geogebra.org and just put the formula you want for any 2D-curve you like. Export the result as an .EPS file and Illustrator will read it beautifully!!!

 

Have fun!

Edited by Rei1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...