Graphing with Blender?

(Aquiva) #1

Hey is it possible to graph with blender?

(I mean, I don’t get why not … with all the curve functions and CAD stuff…)

0 Likes

(Orinoco) #2

If you mean, can you build a three dimensional graph from data, yes, if you do it by hand. “Graphing” something generally means taking input from spreadsheet cells and automatically displaying them in some three dimensional form. All the pieces are in place, I’d imagine the array modifier would be a perfect tool for building three dimensional graphs, the only thing missing is a way to import the data and apply it to the array modifiers properly. Doing that would probably require a bit of python programming, and, as far as I know, no one has taken the time to do that yet.

If you are interested in getting something like that going, you’d either have to do the programming yourself, or find someone who can program to take it on as an interesting project.

0 Likes

(Inmare) #3

There was a Python script that could build charts, at least bar charts. Hm… can’t find it now, sorry. Try searching here or via Google.

0 Likes

(Aquiva) #4

That too … but what I meant more, was doing something like:
Add -> Curve -> Formula
then you would enter your formula: “y=2x” … and bingo, it would graph. “y=2cos(5)” …
And you could do 3D graphs too using y x and z.

you know, like you would do it on a Texas Instrument Calculator … except, in Blender.

0 Likes

(Craig Jones) #5

You could use Python language scripting for this, you would need to construct a small script that would allow input of your formula and then generate mesh or curves based on that data input. Not too complicated, but very complicated for those not knowing Python.

0 Likes

(forTe) #6

Here’s a script I whipped up pretty quick demonstrating the basics of doing it in python. It could be extended upon much more. It has access to all functions in the python math library (sine, cosine, tan, atan, sqrt, etc…, you can google to find out all the functions)

Quick Summary of use:
resultion- sets the number of points to graph (more points = smoother curve)
max/min ‘XYZ’ - maximum and minimum ranges to generate the points in. I tested it with a cubic “domain” (not true mathematical domain). Not sure how it responds to non-cubic, especially since its just a proof of concept

fx - Function of x -> f(x)
fy - Function of y -> f(y)
fz - Function of z -> f(z)

These fx/fy/fz are where you put your code to be evaluated. The script takes care of the rest…


import Blender
from Blender import *
from math import *

resolution = 500

maxX = 20
minX = -20
maxY = 20
minY = -20
maxZ = 20
minZ = -20

xInc = float(maxX - minX)/resolution
yInc = float(maxY - minY)/resolution
zInc = float(maxZ - minZ)/resolution

mesh = Mesh.New('Graph')

for i in xrange(resolution):
    x = minX + (xInc * i)
    y = minY + (yInc * i)
    z = minZ + (zInc * i)
    
    fx = sin(x)
    fy = cos(y)
    fz = sqrt(z)
    
    mesh.verts.extend(fx, fy, fz)

for k in xrange(len(mesh.verts)):
    try:
        mesh.edges.extend(mesh.verts[k], mesh.verts[k+1])
        
    except:
        pass
    
    
scn = Scene.GetCurrent()
scn.objects.new(mesh, 'Graph')

Blender.Redraw()

0 Likes

(Orinoco) #7

Great! :smiley: Now, if some one wants to be really slick, :wink: they’d figure out a way to import the output of a program like Mathematica or MatLab, so we could extend those program’s (fairly lame compared to Blender’s) 3D graphing capabilities. :yes:

0 Likes

(Manda) #8

Hi ,

I found a another script.

http://blender.jp/modules/newbb/viewtopic.php?viewmode=flat&topic_id=757&forum=5
(This page is Japanese)

It generates an IPO Curve or a Mesh from CSV file.

0 Likes

(Hans.P.G.) #9

Thanks a lot for showing my script, Manda. (I found your mention just now and I’m sorry for being late to reply it.) My script is now available for English and please visit here, in which the script is located and a bit tut on how to import a csv file and to create an Ipo curve is explained. If you still have trouble with making a graph with Blender, I really recommend that you take a look at the page I linked above and think of trying to use the script once.

Thanks,

0 Likes

(garuhhh) #10

hi forte! that’s a great script, i’m gonna try it as soon as i get to my pc. by the way, is there any possibility of using an implicit function? like in your script (i’m not really very familiar with python) y, x and z are explicitly defined by an equation, what if a single equation is involved, and it used all three variables, and extracting a particular variable in terms of the other two will not be easy…

0 Likes

(Hans.P.G.) #11

@garuhhh: I also think it would be difficult to deal with graphing an implicit equation and the script has no capability to do it so far. As I wrote at the page for the script, there is another good software in the world to calculate such things mathematically like Mathematica, Maxima, MATLAB, Scilab or something, regardless of cost to use, so first you can calculate an implicit equation with those software and save the result as a csv file and then you can import it with the script into Blender. I wonder if this collaboration among two types of software and the script will make your development faster. Actually I made a video for introduction of a robot walk in the same way.

0 Likes

(garuhhh) #12

thanks for the info hans…i’ve used matlab before, but it costs too much! octave seems to be an option to me, though haven’t used it for graphing…not sure if it will work. :smiley: i’m not familiar with mathematica, maxima, or scilab.

0 Likes