I'm developing a 2 DOF SCARA with inverse kinematics. It works fine at any desired point, but how can I draw a line? Is there an efficient algorithm to do this?
You can define your line as a sequence of very close points, and then just move from one to the next. If you don't want the SCARA arm to "move, stop, move, stop" you can set the target point to the next one once the arm is 80 or 90 percent to the current target point.
EDIT (added example)
Let's say you want the robot to move its tool from (1, 1) to (2, 3). Break that line into, say, 10 segments (actually 9 segments with 10 points including the endpoints). The number of segments will depend on the accuracy you require, since the robot will not move in a straight line between its target points. If you need more accuracy, divide the line into more segments.
First, position the robot at (1, 1). The next point along the line, using the 10 points, would be (1.1, 1.2). Tell the robot to move there, but when its x value reaches, say, 1.08, command it to move to the next point (1.2, 1.4). I hope you can see how this method can be built into a couple of loops in your code.
Alternately, you can use velocity control (using the derivative of your kinematics) to tell it to move in a particular direction, and then update that direction continuously as it moves along the line.