Take the 2-minute tour ×
Graphic Design Stack Exchange is a question and answer site for Graphic Design professionals, students, and enthusiasts. It's 100% free, no registration required.

Is there a direct method of using the Photoshop pen tool (or any other tool) to trace the equation of a line in 2D space and create a path from it in a given domain and/or range, provided I define a Cartesian coordinate system with an origin and two axes?

It would be cool if it could do this!

share|improve this question
add comment

2 Answers 2

up vote 3 down vote accepted

No, there is no native way to do this. There might be a plugin but Photoshop does not have any graphing functionality. You're best bet is to find a graphing application that can export something like .CAD, .SVG, or .EPS.

In fact if looking for plugins you'd probably be better off looking for an Illustrator plugin than a photoshop one as equations of lines are vector in nature. You'll have to look a few up and find which works best for your system.

share|improve this answer
    
Ah, thanks. A graphing program which exports SVG would be perfect, so I'll hunt around for that. –  srynznfyra Jan 14 at 19:52
    
MATLAB or Mathematica possibly? –  horatio Jan 14 at 21:45
2  
Sledgehammers and nuts come to mind. –  srynznfyra Jan 14 at 21:50
add comment

One could be made. Its not terribly hard if you can make a few approximations. While I agree that mathematica and matlab are the ways to go for pro users. There are still some free alternatives that come to mind:

But if you insist on using a Photoshop as a hammer here you go (who am I to argue):

#target photoshop

var doc = app.activeDocument;

// place your function here 
//  put t in second array item if  you dont want a  2d parametric plot
function graphMeParametrically(t) {
     return new Array(
               20 * Math.sin(t) + 30,
               20 * Math.cos(t) +30
               );   
 }

// plot half arc centered on 30, 30
plotLinear(0., 3.14/10, 3.14, graphMeParametrically);

// ok so we could do better by estimating the curvature of a continnious function
plotSmooth(0., 3.14/10, 3.14, 0.01, graphMeParametrically);


function plotLinear(start, step, end, func){
    var points = new Array();
    var index = 0;
    for (var t =start;  t <= end; t+=step) {
        points.push(new PathPointInfo());
        points[index].kind = PointKind.CORNERPOINT;
        points[index].anchor = func(t);
        points[index].leftDirection = points[index].anchor;
        points[index].rightDirection = points[index].anchor;
        index+=1;
    }
    var subPath = new Array();
    subPath.push(new SubPathInfo());
    subPath[0].operation = ShapeOperation.SHAPEXOR;
    subPath[0].closed = false;
    subPath[0].entireSubPath = points;
    doc.pathItems.add("", subPath);
}

// this is a  very dirty and naive estimation 
// now updated version
function plotSmooth(start, step, end, delta, func){
    var points = new Array();
    var index = 0;

    for (var t =start;  t <= end; t+=step) {
        points.push(new PathPointInfo());
        points[index].kind = PointKind.SMOOTHPOINT;

        now =  func(t);
        next =  func(t + step);
        mag = Math.sqrt(Math.pow(next[0] - now[0], 2) + Math.pow(next[1] - now[1], 2)) /3;
        t1 = func(t + delta);
        t2 = func(t - delta);
        mag2 = Math.sqrt(Math.pow(t1[0] - t2[0], 2) + Math.pow(t1[1] - t2[1], 2)) 
        tan1 = new Array(now[0]-mag/mag2*(t2[0] - t1[0]), now[1]-mag/mag2*(t2[1] - t1[1]))
        tan2 = new Array(now[0]+mag/mag2*(t2[0] - t1[0]), now[1]+mag/mag2*(t2[1] - t1[1]))
        points[index].anchor = now;
        points[index].leftDirection = tan1;
        points[index].rightDirection = tan2;
        index+=1;
    }
    var subPath = new Array();
    subPath.push(new SubPathInfo());
    subPath[0].operation = ShapeOperation.SHAPEXOR;
    subPath[0].closed = false;
    subPath[0].entireSubPath = points;
    doc.pathItems.add("", subPath);
}

Edit the function and put this in a .jsx file the for example drag and drop on Photoshop. This will make 2 paths in your Photoshop document that can then be stroked if you like one segmented, and one that guestimates curvature. Try other curves as well.

share|improve this answer
    
It would be cool to know if anybody actually uses this for anything so let me know if you find any use for this. –  joojaa Feb 25 at 20:38
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.