|
|
|
|
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Hi,
I was wondering if any of you knew how to make the following red
isosurface into something that look more like the yellow cylinder CSG?
ie. scaling the sinusoidal shape of the isosurface, but keeping the
small radius it has.
Here's my code for the iso:
#declare a = 100;
#declare b = 25;
isosurface {
function { a*x*x + a*y*y + b*x*cos(z*2*pi) + b*y*sin(z*2*pi) }
[...]
}
Thanks,
Simon
Post a reply to this message
Attachments:
Download 'iso-ifs.png' (47 KB)
Preview of image 'iso-ifs.png'
|
|
| |
| |
|
|
|
|
| |
| |
|
|
> I was wondering if any of you knew how to make the following red
> isosurface into something that look more like the yellow cylinder CSG?
> ie. scaling the sinusoidal shape of the isosurface, but keeping the
> small radius it has.
I assume you want to have a coil. Here is mine:
#macro pre_coil (l,r2,r1,steepness)
#local rmax=(r1)+(r2);
#local dmax=rmax*sqrt(2);
#local omeg=(steepness)/(r2);
#local pre_plane_stretch=1/(1+omeg*omeg);
#local plane_stretch=sqrt(pre_plane_stretch);
#local sqrsum=function(a,b) {a*a+b*b}
#local sqrsum_=function(a,b,c) {a*a+b*b+c*c}
#local coil_aux1=function(a_,b,c)
{atanf(c*cos(a_)+b*sin(a_),b*cos(a_)-c*sin(a_))}
#local coil_aux2=function(r,phi) {sqrsum(r-(r2),plane_stretch*r*phi)}
isosurface {
function {coil_aux2(sqrt(sqrsum(y,z)),coil_aux1(omeg*x,y,z))}
contained_by {box {<0,-rmax,-rmax> <l,rmax,rmax>}}
threshold (r1)*(r1)
max_gradient 2*max(r2,sqrt(sqrsum_(
(dmax-(r2)+pi*pi*pre_plane_stretch*dmax),
(pi*pre_plane_stretch*dmax)
(pi*omeg*pre_plane_stretch*dmax*dmax))))
all_intersections
}
#end
is wraps around the line from <0,0,0> to <l,0,0>.
r1 and r2 are like the small and large radius of a torus.
steepness is the ratio of swirling to moving:
0 gives a straight cylinder, 1 gives an angle of 45 degrees,
-1 also, but in the other direction.
The usual screw will have positive steepness.
Comments welcome.
Mark
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Sorry, just noticed something missing. This uses atanf,
which is a function that does what I think atan2 should
(given two coordinates y and x it computes the angle of
the polar coordinates of the point (x,y)). Here it is:
#declare atan_aux1=function(a,b) {atan2(min(a,b),max(a,b))}
#declare atan_aux2=function(a,b,aa,ba) {
(2*(aa>ba)-1)*
(2*(a>0)-1)*
(2*(b>0)-1)*
atan_aux1(aa,ba)
}
#declare atan_aux3=function(a,b,aa,ba) {
(1+(aa>ba)*(2*(a<=0)-1))*(2*(b>0)-1)
}
#declare atan_aux4=function(a,b,aa,ba) {
atan_aux3(a,b,aa,ba)*pi/2+atan_aux2(a,b,aa,ba)
}
#declare atanf=function(b,a) {
atan_aux4(a,b,abs(a),abs(b))
}
And while I am looking at the code: This may be faster:
#macro pre_coil (l,r2,r1,steepness)
#local rmax=(r1)+(r2);
#local dmax=rmax*sqrt(2);
#local omeg=(steepness)/(r2);
#local pre_plane_stretch=1/(1+omeg*omeg);
#local plane_stretch=sqrt(pre_plane_stretch);
#local sqrsum=function(a,b) {a*a+b*b}
#local sqrsum_=function(a,b,c) {a*a+b*b+c*c}
#local coil_aux1=function(ca,sa,b,c) {atanf(c*ca+b*sa,b*ca-c*sa)}
#local coil_aux2=function(a_,b,c) {coil_aux1(cos(a_),sin(a_),b,c)}
#local coil_aux3=function(r,phi) {sqrsum(r-(r2),plane_stretch*r*phi)}
isosurface {
function {coil_aux3(sqrt(sqrsum(y,z)),coil_aux2(omeg*x,y,z))}
contained_by {box {<0,-rmax,-rmax> <l,rmax,rmax>}}
threshold (r1)*(r1)
max_gradient 2*max(r2,sqrt(sqrsum_(
(dmax-(r2)+pi*pi*pre_plane_stretch*dmax),
(pi*pre_plane_stretch*dmax)
(pi*omeg*pre_plane_stretch*dmax*dmax))))
all_intersections
}
#end
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Geez... Maybe you could explain to me how to modify my isosurface.
My problem is that I don't actually want a coil, I want much more, but
as a start, a coil would be fine!
Is it possible to have my isosurface make a "round" shape on the z axis
between (-x), (x), (-y) and (y), given a sinusoidal function that I
would define myself like this:
#macro myFunc(xy, z)
#if(xy == 0)
d*cos(z)
#else
d*sin(z)
#end
#end
(not sure if syntax is alright, but that's what my function would
basically look like)
Thanks Mark,
Simon
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
> Is it possible to have my isosurface make a "round" shape on the z axis
> between (-x), (x), (-y) and (y), given a sinusoidal function that I
> would define myself like this:
> #macro myFunc(xy, z)
> #if(xy == 0)
> d*cos(z)
> #else
> d*sin(z)
> #end
> #end
I still do not quite understand, what you want.
I assume at least that it could be described by
some 2-dimensional shape that is rotated around
the z-axis as it moves along the same. In that
case you need to describe the 2D shape by some
2D isosurface (isoperimeter, that is). Lets say
that is described by f(x,y)=c. Then the 3D-shape
is described by
f(x*cos(w*z)+y*sin(w*z),y*cos(w*z)-x*sin(w*z))=c
which gives an isosurface all right. Now what I
need to know is: What is your 2D-shape? In your
scene it is defined by
a*(x^2+y^2)+b*x=c
or, equivalently,
(x+b/2a)^2+y^2=c/a+(b/2a)^2
Now this is a circle with center (-b/2a,0) and
radius sqrt(c/a+(b/2a)^2). Maybe you would be
more happy with an ellipse? To define one with
radii rx in x-direction, ry in y-direction and
center (cx,cy) take
f(x,y)=((x-cx)/rx)^2+((y-cy)/ry)^2
and threshold 1. I do not know the scale in your
scene, but maybe you would like to try
w=1/3, cx=2, cy=0, rx=3, ry=1
Regards,
Mark
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
> I still do not quite understand, what you want.
I'm sorry if I don't explain myself correctly...
> I assume at least that it could be described by
> some 2-dimensional shape that is rotated around
> the z-axis as it moves along the same.
That's it...
> In that
> case you need to describe the 2D shape by some
> 2D isosurface (isoperimeter, that is). Lets say
> that is described by f(x,y)=c. Then the 3D-shape
> is described by
> f(x*cos(w*z)+y*sin(w*z),y*cos(w*z)-x*sin(w*z))=c
> which gives an isosurface all right. Now what I
> need to know is: What is your 2D-shape? In your
> scene it is defined by
> a*(x^2+y^2)+b*x=c
> or, equivalently,
> (x+b/2a)^2+y^2=c/a+(b/2a)^2
> Now this is a circle with center (-b/2a,0) and
> radius sqrt(c/a+(b/2a)^2). Maybe you would be
> more happy with an ellipse? To define one with
> radii rx in x-direction, ry in y-direction and
> center (cx,cy) take
> f(x,y)=((x-cx)/rx)^2+((y-cy)/ry)^2
> and threshold 1. I do not know the scale in your
> scene, but maybe you would like to try
> w=1/3, cx=2, cy=0, rx=3, ry=1
The circle is the shape I'm looking for, probably an elipse would make a
better result but it would have to rotate onto its center to make the
scene look right. The circle is good!
So grabbing what you showed me, I guess this might give the results I'm
looking for...
#declare R = 0.1;
#declare Circle = function { pow(((x)/R),2)+pow(((y)/R), 2) }
isosurface {
function { Circle(x*cos(w*z)+y*sin(w*z),y*cos(w*z)-x*sin(w*z)) }
[...]
}
Though, this gives me error in MegaPov, so I wasn't able to see the
results, I believe I missed something somewhere. It tells me that
instead of the first pow in the Circle function, it was looking for a
float factor. What should I do?
Thanks,
Simon
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
> So grabbing what you showed me, I guess this might give the results I'm
> looking for...
>
> #declare R = 0.1;
> #declare Circle = function { pow(((x)/R),2)+pow(((y)/R), 2) }
> isosurface {
> function { Circle(x*cos(w*z)+y*sin(w*z),y*cos(w*z)-x*sin(w*z)) }
> [...]
> }
>
> Though, this gives me error in MegaPov, so I wasn't able to see the
> results, I believe I missed something somewhere. It tells me that
> instead of the first pow in the Circle function, it was looking for a
> float factor. What should I do?
OK. Some comments:
- Add (x,y) after function in the definition of Circle.
- declare w somewhere. It determines how fast the shape turns.
Try 1 and adjust as needed.
- Your shape is a circle with the origin as center. As you turn this
around the origin, nothing changes. Perhaps you want to move the
center somewhere else. That's what cx and cy were for. To make it
clear: This is the center _prior_ to turning. In fact the ,,real''
center will move along a spiral.
Yours,
Mark
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Oh, and don't forget threshold 1 and a high enough
max_gradient. I did not see anything before I used
maxgradient 10000. But that was experimental.
Mark
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Simon Lemieux wrote:
>Hi,
> I was wondering if any of you knew how to make the following red
>isosurface into something that look more like the yellow cylinder CSG?
>ie. scaling the sinusoidal shape of the isosurface, but keeping the
>small radius it has.
....
You may try the code below.
Tor Olav
// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7
// Copyright 2002 by Tor Olav Kristensen
// Email: t o r _ o l a v _ k [ a t ] h o t m a i l . c o m
// http://home.no/t-o-k
// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7
#version 3.5;
#include "functions.inc"
// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7
#declare IntervalFn =
function(A, I, S) {
mod(A - S + select(A - S, -1, 1)*I/2, I)
- select(A - S, -1, 1)*I/2
}
#declare yFn =
function(x, y, z, I) { IntervalFn(y, I, I/2*atan2(z, x)/pi) }
// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7
#declare Rmaj = 12;
#declare Rmin = 1;
#declare Interval = 10;
isosurface {
function { f_torus(x, yFn(x, y, z, Interval), z, Rmaj, Rmin) }
contained_by {
box {
-<Rmaj + Rmin, 25, Rmaj + Rmin>,
<Rmaj + Rmin, 25, Rmaj + Rmin>
}
}
// max_gradient 10
pigment { color rgb <1, 1, 1> }
}
// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7
background { color blue 0.5 }
light_source {
<1, 1, -1>*100
color rgb <1, 1, 1>
}
camera {
location <2, 0, -1>*30
look_at 0*y
}
// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
|
|