This is something of an aside - I don't know what I'm doing yet, well
enough to implement this via jhs, but here's an ellipsoid:

https://www.shadertoy.com/view/XtlGDX

You can tweak the a, b, and c radius values near the top of the script
(which should display on the right side of the screen) and hit the
play button to see the change.

Thanks,

-- 
Raul

On Fri, Mar 6, 2015 at 10:38 PM, Skip Cave <s...@caveconsulting.com> wrote:
> Looking a bit better, but no cigar:
>
> a=:3[b=:3[c=:3
>
>  X=:4 :0
>
> a*(cos x)*cos y
>
> )
>
>  Y=:4 :0
>
> b*(cos x)*sin y
>
> )
>
>  Z=:3 :0
>
> c*(sin y)
>
> )
>
> steps=: 3 : 'a+(w)*(i.n+1)%n[w=.z-a[''a z n''=.y'
>
> draw=:3 :0
>
> angles=: steps _1p1 1p1 100
>
> uangles =: steps _1.5708 1.5708 100
>
> x=. uangles X"0 _ angles
>
> y=. uangles Y"0 _ angles
>
> z=. Z uangles
>
> 'surface' plot x;y;z
>
> )
>
>  draw''
>
>
> output at: http://bit.ly/1wNlQe3
>
>
> Skip Cave
> Cave Consulting LLC
>
> On Fri, Mar 6, 2015 at 9:18 PM, Raul Miller <rauldmil...@gmail.com> wrote:
>
>> steps=: 3 : 'a+(w)*(i.n+1)%n[w=.z-a[''a z n''=.y'
>>
>> Thanks,
>>
>> --
>> Raul
>>
>> On Fri, Mar 6, 2015 at 10:08 PM, Skip Cave <s...@caveconsulting.com>
>> wrote:
>> > Here's what I got whaen I ran Jon's code:
>> >
>> > a=:3[b=:3[c=:3
>> >
>> >  X=:4 :0
>> >
>> > a*(cos x)*cos y
>> >
>> > )
>> >
>> >  Y=:4 :0
>> >
>> > b*(cos x)*sin y
>> >
>> > )
>> >
>> >  Z=:3 :0
>> >
>> > c*(sin y)
>> >
>> > )
>> >
>> >  draw=:3 :0
>> >
>> > angles=: steps _1p1 1p1 100
>> >
>> > uangles =: steps _1.5708 1.5708 100
>> >
>> > x=. uangles X"0 _ angles
>> >
>> > y=. uangles Y"0 _ angles
>> >
>> > z=. Z uangles
>> >
>> > 'surface' plot x;y;z
>> >
>> > )
>> >
>> >  draw''
>> >
>> > |value error: steps
>> >
>> > | angles=: steps _3.14159 3.14159 100
>> >
>> >
>> > Skip Cave
>> > Cave Consulting LLC
>> >
>> > On Fri, Mar 6, 2015 at 8:56 PM, Jon Hough <jgho...@outlook.com> wrote:
>> >
>> >>
>> >> I butchered Raul's script slightly. But the resulting graph is still
>> >> weird. Not sure if it's an improvement.
>> >>
>> >>
>> >> a=:3[b=:3[c=:3
>> >>
>> >>
>> >>
>> >> X=:4 :0
>> >>
>> >>
>> >>
>> >>   a*(cos x)*cos y
>> >>
>> >>
>> >>
>> >> )
>> >>
>> >>
>> >>
>> >>
>> >>
>> >>
>> >> Y=:4 :0
>> >>
>> >>
>> >>
>> >>   b*(cos x)*sin y
>> >>
>> >>
>> >>
>> >> )
>> >>
>> >>
>> >>
>> >>
>> >>
>> >>
>> >> Z=:3 :0
>> >>
>> >>
>> >>
>> >> c*(sin y)
>> >>
>> >>
>> >>
>> >> )
>> >>
>> >>
>> >>
>> >>
>> >>
>> >>
>> >> draw=:3 :0
>> >>
>> >>
>> >>
>> >>   angles=: steps _1p1 1p1 100
>> >>
>> >>
>> >>
>> >>   uangles =: steps _1.5708 1.5708 100
>> >>
>> >>
>> >>
>> >>   x=. uangles X"0 _ angles
>> >>
>> >>
>> >>
>> >>   y=. uangles Y"0 _ angles
>> >>
>> >>
>> >>
>> >>
>> >>
>> >> z=.  Z uangles
>> >>
>> >>
>> >>
>> >>   'surface' plot x;y;z
>> >>
>> >>
>> >>
>> >> )
>> >>
>> >>
>> >>
>> >>
>> >> draw''
>> >>
>> >> > From: jgho...@outlook.com
>> >> > To: programm...@jsoftware.com
>> >> > Date: Sat, 7 Mar 2015 02:46:35 +0000
>> >> > Subject: Re: [Jprogramming] Plotting a 3D Ellipse
>> >> >
>> >> > It seems you are using [-pi,pi] as the range of all your angles.I
>> think
>> >> you need to use [-pi/2,pi/2] as the range for the u argument (in the
>> >> wikipedia page).
>> >> >
>> >> > > From: rauldmil...@gmail.com
>> >> > > Date: Fri, 6 Mar 2015 21:35:37 -0500
>> >> > > To: programm...@jsoftware.com
>> >> > > Subject: Re: [Jprogramming] Plotting a 3D Ellipse
>> >> > >
>> >> > > Hmm...
>> >> > >
>> >> > > I notice that load'graph' no longer provides the steps verb
>> mentioned
>> >> > > in http://www.jsoftware.com/books/pdf/expmath.pdf
>> >> > >
>> >> > > So here's a workalike:
>> >> > >    steps=: 3 : 'a+(w)*(i.n+1)%n[w=.z-a[''a z n''=.y'
>> >> > >
>> >> > > and that gives us an example of a surface plot.
>> >> > >
>> >> > > Next, we need a parametric representation of the ellipse, and
>> >> > > http://en.wikipedia.org/wiki/Ellipsoid#Parameterization looks like
>> a
>> >> > > plausible approach there.
>> >> > >
>> >> > > Using that, and http://www.jsoftware.com/help/jforc/graphics.htm
>> as a
>> >> > > starting point, it seems to me that I ought to be able to draw an
>> >> > > ellipse like this:
>> >> > >
>> >> > > a=:3[b=:4[c=:5
>> >> > >
>> >> > > X=:4 :0~
>> >> > >   a*(cos x)*/cos y
>> >> > > )
>> >> > >
>> >> > > Y=:4 :0~
>> >> > >   b*(cos x)*/sin y
>> >> > > )
>> >> > >
>> >> > > Z=:4 :0~
>> >> > >   c*(sin x)*/1: y
>> >> > > )
>> >> > >
>> >> > > draw=:3 :0
>> >> > >   angles=: steps _1p1 1p1 100
>> >> > >   x=. X angles
>> >> > >   y=. Y angles
>> >> > >   z=. Z angles
>> >> > >   'surface' plot x;y;z
>> >> > > )
>> >> > >
>> >> > > draw''
>> >> > >
>> >> > > Sadly, that's not an ellipse.
>> >> > >
>> >> > > But I do not have enough familiarity with plot to know whether I've
>> >> > > screwed up my math or if there's a defect in plot -- I don't know
>> how
>> >> > > to isolate the problem.
>> >> > >
>> >> > > That said, a quick test with a 3d model of a cube:
>> >> > >
>> >> > >    'surface' plot ;/|:#:i.8
>> >> > > |NaN error: ncile
>> >> > >
>> >> > > ...suggests that plot isn't really designed to represent 3d solids.
>> >> > >
>> >> > > Still, that does not eliminate any potential errors on my part.
>> >> > >
>> >> > > On the other hand, maybe the right approach would be to use jhs and
>> >> > > generate a distance field renderer along the lines of what you see
>> at
>> >> > > shadertoy.com.
>> >> > >
>> >> > > I'll have to think a bit to see if I can pull off something like
>> that.
>> >> > > (I think that that would only work for people who have adequate
>> >> > > graphics hardware support. But I think you have a suitable graphics
>> >> > > card?)
>> >> > >
>> >> > > Thanks,
>> >> > >
>> >> > > --
>> >> > > Raul
>> >> > >
>> >> > >
>> >> > > On Fri, Mar 6, 2015 at 7:10 PM, Skip Cave <s...@caveconsulting.com>
>> >> wrote:
>> >> > > > I want to plot a 3D ellipse (ellipsoid) and then be able to change
>> >> the
>> >> > > > lengths of the three axes. The equation of an ellipse with axis
>> >> lengths of
>> >> > > > a, b, & c is:
>> >> > > >
>> >> > > >  ((x^2)%(a^2)) + ((y^2)%(b^2)) + ((z^2)%(c^2)) = 1
>> >> > > >
>> >> > > > How can I arrange this so it can be plotted in a 3-D plot in J,
>> and
>> >> then be
>> >> > > > able to  experiment with the lengths of the axes?
>> >> > > >
>> >> > > > Skip
>> >> > > >
>> >> > > > Skip Cave
>> >> > > > Cave Consulting LLC
>> >> > > >
>> >> ----------------------------------------------------------------------
>> >> > > > For information about J forums see
>> >> http://www.jsoftware.com/forums.htm
>> >> > >
>> ----------------------------------------------------------------------
>> >> > > For information about J forums see
>> http://www.jsoftware.com/forums.htm
>> >> >
>> >> > ----------------------------------------------------------------------
>> >> > For information about J forums see
>> http://www.jsoftware.com/forums.htm
>> >>
>> >> ----------------------------------------------------------------------
>> >> For information about J forums see http://www.jsoftware.com/forums.htm
>> >>
>> > ----------------------------------------------------------------------
>> > For information about J forums see http://www.jsoftware.com/forums.htm
>> ----------------------------------------------------------------------
>> For information about J forums see http://www.jsoftware.com/forums.htm
>>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to