Discussion:
[NTG-context] graphics
Hans Hagen
2018-12-04 17:03:14 UTC
Permalink
Hi,

As most mechanism are reasonable okay now we can look into what future
versions of ConteXt should provide in terms of functionality. The
(luatex) engine is also more of less finished or at least stable in
terms of functionality.

One possible area of further development is graphics so I'd like to know
if there are (reasonable) demands for more graphics support using
metapost. Alan and I are on-and-off working on some extensions and one
of the things we discuss is visualization of data. The question is of
course what should be done in the lua/mp/tex combination and what
externally but the combination has some advantages. There has been
presentations and discussions at the last meeting and graphics is always
a nice topic, and also kind of rewarding in terms of development.

Of course other demands can be formulated too, but these then need to
come with well defined descriptions (or mockup examples).

Hans

-----------------------------------------------------------------
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-***@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
__________________________________
Alan Braslau
2018-12-04 18:54:54 UTC
Permalink
On Tue, 4 Dec 2018 18:03:14 +0100
Post by Hans Hagen
Hi,
As most mechanism are reasonable okay now we can look into what
future versions of ConteXt should provide in terms of functionality.
The (luatex) engine is also more of less finished or at least stable
in terms of functionality.
One possible area of further development is graphics so I'd like to
know if there are (reasonable) demands for more graphics support
using metapost. Alan and I are on-and-off working on some extensions
and one of the things we discuss is visualization of data. The
question is of course what should be done in the lua/mp/tex
combination and what externally but the combination has some
advantages. There has been presentations and discussions at the last
meeting and graphics is always a nice topic, and also kind of
rewarding in terms of development.
Of course other demands can be formulated too, but these then need to
come with well defined descriptions (or mockup examples).
Hans is alluding to work that we are doing to explore the possibilities
of lua + MetaPost in the treatment and visualization of data,
efficiently, with the possibility of handling large quantities of data.
Lua does this particularly well.

My first exercise has been a complete rewrite of the John Hobby graph
macros. It was/is an exercise in recreating the functionality "from
scratch", trying to use lua effectively when needed. The code and
approach is entirely new. My use case was the analysis of a large set
of data - entirely ridiculous for graphical display but containing
"outliers" or instances that are significant, and it works! I am
trying to generalize, and am doing this in my "free time".

So the aim is two-fold:

1) to efficiently handle large datasets through the use of lua

2) to generalize the notion of user data space from the
two-dimensional drawing space of MetaPost (and the represented page),
and affine transformations of this 2D space to other coordinate
systems and dimensions. We are not thinking about 3D rendering or
raytracing, but rather simple projections and other transformations
such as polar coordinates. (Of course, log scales, for example are a
"simple" non-linear transformation.)

I guess that Hans would like to expand the discussion to the future of
graphics in general, inviting input from everybody.

Alan
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-***@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
________________________________________________________
Taco Hoekwater
2018-12-05 09:02:45 UTC
Permalink
Post by Alan Braslau
2) to generalize the notion of user data space from the
two-dimensional drawing space of MetaPost (and the represented page),
and affine transformations of this 2D space to other coordinate
systems and dimensions. We are not thinking about 3D rendering or
raytracing, but rather simple projections and other transformations
such as polar coordinates. (Of course, log scales, for example are a
"simple" non-linear transformation.)
On this note: I would like to have an ‘official’ way to map 3D coordinates
to 2D coordinates with for a camera position with an orthogonal window.

Not the most complicated thing in the world, but it would be nice if
metafun had an ‘official’ way of setting up a scene.

Best wishes,
Taco



___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-***@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
_____________________________________________________________________________
Hans Hagen
2018-12-05 12:59:35 UTC
Permalink
Post by Taco Hoekwater
Post by Alan Braslau
2) to generalize the notion of user data space from the
two-dimensional drawing space of MetaPost (and the represented page),
and affine transformations of this 2D space to other coordinate
systems and dimensions. We are not thinking about 3D rendering or
raytracing, but rather simple projections and other transformations
such as polar coordinates. (Of course, log scales, for example are a
"simple" non-linear transformation.)
On this note: I would like to have an ‘official’ way to map 3D coordinates
to 2D coordinates with for a camera position with an orthogonal window.
Not the most complicated thing in the world, but it would be nice if
metafun had an ‘official’ way of setting up a scene.
sounds like a challenge for our meta-math-magician Alan

Hans

-----------------------------------------------------------------
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-***@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
__________________________________
Alan Braslau
2018-12-05 15:24:53 UTC
Permalink
On Wed, 5 Dec 2018 13:59:35 +0100
Post by Hans Hagen
Post by Taco Hoekwater
On this note: I would like to have an ‘official’ way to map 3D
coordinates to 2D coordinates with for a camera position with an
orthogonal window.
Not the most complicated thing in the world, but it would be nice if
metafun had an ‘official’ way of setting up a scene.
sounds like a challenge for our meta-math-magician Alan
Not a particularly hard problem (well known) but then one will want
hidden line removal, (partial) transparency, shading, ... and whereas
this is possible, it becomes complicated (and one will then want
animation).

For now, in my simple use of 3D to create diagrams, not any attempt to
make phluffy* images, I am quite content with a simple "caviler"
projection (infinite view position).

Alan

*Tufte's phluff!
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-***@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
_____________________________________________________
Procházka Lukáš Ing.
2018-12-06 07:31:42 UTC
Permalink
Hello,

would it be possible to provide some samples finally?

That would be very handy especially for those who are used to create plots via "several clicks on Excel ribbon".

Personally, I am interested in 2D plots to be created loading (an) external data file(s) (text files formed into tables with some headers and comments marked by a letter in the beginning of the line), often altered by Lua somehow (e.g. trimming "bad" values).
I am used to use tickz/pgfplots for this purpose; use of pgfplots is (probably) very powerful but one has to study a lot of pages to create a simple plot followed by many try-and-see.
Also, support for showing extremal values (local extremes) in 2d plots is something handy.

"My" typical 2d plot looks:

A
|
30 | 24.1 <- local extreme
| +
20 | --- --- 15.6 <- local extreme
|/ \ +
10 | -- ---
|
+----------------------------------------->
10. 20. 30. 40.

Best regards,

Lukas
Post by Alan Braslau
On Tue, 4 Dec 2018 18:03:14 +0100
Post by Hans Hagen
Hi,
As most mechanism are reasonable okay now we can look into what
future versions of ConteXt should provide in terms of functionality.
The (luatex) engine is also more of less finished or at least stable
in terms of functionality.
One possible area of further development is graphics so I'd like to
know if there are (reasonable) demands for more graphics support
using metapost. Alan and I are on-and-off working on some extensions
and one of the things we discuss is visualization of data. The
question is of course what should be done in the lua/mp/tex
combination and what externally but the combination has some
advantages. There has been presentations and discussions at the last
meeting and graphics is always a nice topic, and also kind of
rewarding in terms of development.
Of course other demands can be formulated too, but these then need to
come with well defined descriptions (or mockup examples).
Hans is alluding to work that we are doing to explore the possibilities
of lua + MetaPost in the treatment and visualization of data,
efficiently, with the possibility of handling large quantities of data.
Lua does this particularly well.
My first exercise has been a complete rewrite of the John Hobby graph
macros. It was/is an exercise in recreating the functionality "from
scratch", trying to use lua effectively when needed. The code and
approach is entirely new. My use case was the analysis of a large set
of data - entirely ridiculous for graphical display but containing
"outliers" or instances that are significant, and it works! I am
trying to generalize, and am doing this in my "free time".
1) to efficiently handle large datasets through the use of lua
2) to generalize the notion of user data space from the
two-dimensional drawing space of MetaPost (and the represented page),
and affine transformations of this 2D space to other coordinate
systems and dimensions. We are not thinking about 3D rendering or
raytracing, but rather simple projections and other transformations
such as polar coordinates. (Of course, log scales, for example are a
"simple" non-linear transformation.)
I guess that Hans would like to expand the discussion to the future of
graphics in general, inviting input from everybody.
Alan
--
Ing. Lukáš Procházka | mailto:***@pontex.cz
Pontex s. r. o. | mailto:***@pontex.cz | http://www.pontex.cz | IDDS: nrpt3sn | IČO: 40763439
Bezová 1658
147 14 Praha 4

Mob.: +420 702 033 396

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-***@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
_____________________________________________________________________________
Henri Menke
2018-12-05 09:14:59 UTC
Permalink
ConTeXt already comes with a full XML parser. SVG is XML. It would be
nice if it was possible to render some subset of SVG.
Post by Hans Hagen
Hi,
As most mechanism are reasonable okay now we can look into what future
versions of ConteXt should provide in terms of functionality. The
(luatex) engine is also more of less finished or at least stable in
terms of functionality.
One possible area of further development is graphics so I'd like to know
if there are (reasonable) demands for more graphics support using
metapost. Alan and I are on-and-off working on some extensions and one
of the things we discuss is visualization of data. The question is of
course what should be done in the lua/mp/tex combination and what
externally but the combination has some advantages. There has been
presentations and discussions at the last meeting and graphics is always
a nice topic, and also kind of rewarding in terms of development.
Of course other demands can be formulated too, but these then need to
come with well defined descriptions (or mockup examples).
Hans
-----------------------------------------------------------------
                                          Hans Hagen | PRAGMA ADE
              Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
       tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-***@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
________________________________________________
luigi scarso
2018-12-05 09:22:13 UTC
Permalink
Post by Henri Menke
ConTeXt already comes with a full XML parser. SVG is XML. It would be
nice if it was possible to render some subset of SVG.
In the mean time, I think we should also consider
Headless Chromium for SVG -> PDF (with --print-to-pdf )
(together with inkscape)
--
luigi
Hans Hagen
2018-12-05 12:37:32 UTC
Permalink
Post by Henri Menke
ConTeXt already comes with a full XML parser. SVG is XML. It would be
nice if it was possible to render some subset of SVG.
So what subset? ... Doing some shapes etc is doable but doing all is
over the top

Hans


-----------------------------------------------------------------
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-***@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
________________________________________________________________________________
luigi scarso
2018-12-05 12:55:49 UTC
Permalink
Post by Hans Hagen
Post by Henri Menke
ConTeXt already comes with a full XML parser. SVG is XML. It would be
nice if it was possible to render some subset of SVG.
So what subset? ... Doing some shapes etc is doable but doing all is
over the top
and of course some <something> will never be enough... never ending story.
The sad story with svg is that is an all-or-nothing thing .
--
luigi
Mikael P. Sundqvist
2018-12-07 08:06:03 UTC
Permalink
Post by Hans Hagen
Hi,
As most mechanism are reasonable okay now we can look into what future
versions of ConteXt should provide in terms of functionality. The
(luatex) engine is also more of less finished or at least stable in
terms of functionality.
One possible area of further development is graphics so I'd like to know
if there are (reasonable) demands for more graphics support using
metapost. Alan and I are on-and-off working on some extensions and one
of the things we discuss is visualization of data. The question is of
course what should be done in the lua/mp/tex combination and what
externally but the combination has some advantages. There has been
presentations and discussions at the last meeting and graphics is always
a nice topic, and also kind of rewarding in terms of development.
Of course other demands can be formulated too, but these then need to
come with well defined descriptions (or mockup examples).
Hans
-----------------------------------------------------------------
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
webpage : http://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___________________________________________________________________________________
Hi,

I don't know if what I describe below is along the lines you ask for,
but here comes two wishes:

1) Full support for drawing implicit curve plots. For some curves,
like a lemniscate
(https://en.wikipedia.org/wiki/Lemniscate_of_Bernoulli) one can easily
succeed by using a parametrisation, but sometimes one end up with
equations and to find a parametrisation might be difficult (not to say
impossible). I asked about this a while ago and got a simple solution
working for that curve, but I think a general working solution would
be neat. I think the bernoulli lemniscate could be a good test curve,
since it intersect itself.

2) Support for transforming images in a more general way. With the
zscaled, slanted, ... we are able to transform any object in an affine
way. It would be nice to be able to transform any object in a more
general way (i.e. by a mapping defined by the user). The example code
below shows what happens in the complex plane with a grid and a curve
when the mapping z to z^2 is applied. Perhaps I am missing something,
but I'm not able to apply this to a piece of text for example, or to
apply it directly to a picture. Instead, I have to loop over all
separate paths. I think the ideal would be to have a "ftransformed"
(or with some other name), and then just define a function (as fun in
the example below), and then be able to do "draw X ftransformed fun;",
where X is some(any?) general object. Is that doable?

/Mikael

%%% Example code
\starttext
\startMPpage[offset=3bp]
u:=3cm;

def fun(expr x,y) = (x**2-y**2,2*x*y) enddef;

def sq(expr kv,s) =
fun(xpart point 0 along kv,ypart point 0 along kv)
for i=s step s until 1: -- fun(xpart point i along kv,ypart point i
along kv) endfor
enddef;

path rp;
rp = (0,-0.8)..(0.7,-0.2)..(0.7,0.6){dir
150}..(-0.7,0.4)..(-0.4,-0.5){dir 0}..cycle;


% Draw the original grid and the path
for i = -1 step 1/10 until 1+eps:
for j = -1 step 1/10 until 1+eps:
draw ((i,-1)--(i,1)) scaled u;
draw ((-1,j)--(1,j)) scaled u;
endfor;
endfor;

draw rp scaled u withcolor darkred withpen pencircle scaled 2bp;

% Draw the grid and curve after map z->z^2
draw image(
for i = -1 step 1/10 until 1+eps:
for j = 0 step 1/10 until 1+eps:
draw (sq(((i,0)--(i,1)),1/100)) scaled u;
draw (sq(((-1,j)--(1,j)),1/100)) scaled u;
endfor;
endfor;
draw (sq(rp,1/100)) scaled u withcolor darkred withpen pencircle scaled 2bp;
) xshifted 2.5u;

\stopMPpage
\stoptext
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-***@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
_________________________________________________________________
luigi scarso
2018-12-07 12:20:35 UTC
Permalink
Post by Hans Hagen
Post by Hans Hagen
Hi,
As most mechanism are reasonable okay now we can look into what future
versions of ConteXt should provide in terms of functionality. The
(luatex) engine is also more of less finished or at least stable in
terms of functionality.
One possible area of further development is graphics so I'd like to know
if there are (reasonable) demands for more graphics support using
metapost. Alan and I are on-and-off working on some extensions and one
of the things we discuss is visualization of data. The question is of
course what should be done in the lua/mp/tex combination and what
externally but the combination has some advantages. There has been
presentations and discussions at the last meeting and graphics is always
a nice topic, and also kind of rewarding in terms of development.
Of course other demands can be formulated too, but these then need to
come with well defined descriptions (or mockup examples).
Hans
-----------------------------------------------------------------
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
Post by Hans Hagen
If your question is of interest to others as well, please add an entry
to the Wiki!
http://www.ntg.nl/mailman/listinfo/ntg-context
Post by Hans Hagen
webpage : http://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___________________________________________________________________________________
Hi,
I don't know if what I describe below is along the lines you ask for,
1) Full support for drawing implicit curve plots. For some curves,
like a lemniscate
(https://en.wikipedia.org/wiki/Lemniscate_of_Bernoulli) one can easily
succeed by using a parametrisation, but sometimes one end up with
equations and to find a parametrisation might be difficult (not to say
impossible).
sure, see eg
https://math.stackexchange.com/questions/904782/is-there-a-general-way-to-parameterize-all-implicit-functions
--
luigi
Alan Braslau
2018-12-07 15:15:48 UTC
Permalink
On Fri, 7 Dec 2018 09:06:03 +0100
Post by Mikael P. Sundqvist
2) Support for transforming images in a more general way. With the
zscaled, slanted, ... we are able to transform any object in an affine
way. It would be nice to be able to transform any object in a more
general way (i.e. by a mapping defined by the user). The example code
below shows what happens in the complex plane with a grid and a curve
when the mapping z to z^2 is applied.
I have generalized my rewrite of the MP graph macros to handle any
arbitrary mapping from data space to drawing (2D) space. At present, I
have only considered the simple functions of log (and sqrt) scales as
well as polar coordinates (x,y) = f(theta,r) with f(theta,r) = (r sin
theta, r cos theta) as I have real use cases for these.

I also consider a simple 3D->2D mapping.

It would be very easy to transform z = a+ib to z^2 for example, as you
show,


The approach transforms a picture, applying to all stroked and
filled paths, as well as to the *position* of text objects. I have not
looked into somehow transforming a bitmap image.
Post by Mikael P. Sundqvist
Perhaps I am missing something,
but I'm not able to apply this to a piece of text for example, or to
apply it directly to a picture. Instead, I have to loop over all
separate paths. I think the ideal would be to have a "ftransformed"
(or with some other name), and then just define a function (as fun in
the example below), and then be able to do "draw X ftransformed fun;",
where X is some(any?) general object. Is that doable?
for i within pic :
...
endfor

So, yes, easy to write a primary (but I don't like the name
"ftransformed"). Using lua helpers can make this efficient.


Alan
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-***@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
_________________________________
Mikael P. Sundqvist
2018-12-08 08:31:46 UTC
Permalink
Post by Alan Braslau
On Fri, 7 Dec 2018 09:06:03 +0100
Post by Mikael P. Sundqvist
2) Support for transforming images in a more general way. With the
zscaled, slanted, ... we are able to transform any object in an affine
way. It would be nice to be able to transform any object in a more
general way (i.e. by a mapping defined by the user). The example code
below shows what happens in the complex plane with a grid and a curve
when the mapping z to z^2 is applied.
I have generalized my rewrite of the MP graph macros to handle any
arbitrary mapping from data space to drawing (2D) space. At present, I
have only considered the simple functions of log (and sqrt) scales as
well as polar coordinates (x,y) = f(theta,r) with f(theta,r) = (r sin
theta, r cos theta) as I have real use cases for these.
Sounds interesting. Do you have any "test document" to show the work
in progress?
Post by Alan Braslau
I also consider a simple 3D->2D mapping.
That sounds awesome!! The time working with colors as 3D might come to
an end! :)
Post by Alan Braslau
It would be very easy to transform z = a+ib to z^2 for example, as you
show,
The approach transforms a picture, applying to all stroked and
filled paths, as well as to the *position* of text objects. I have not
looked into somehow transforming a bitmap image.
You emphasize "position". Does it mean it will not be possible to
transform the shape of the letter?
Post by Alan Braslau
Post by Mikael P. Sundqvist
Perhaps I am missing something,
but I'm not able to apply this to a piece of text for example, or to
apply it directly to a picture. Instead, I have to loop over all
separate paths. I think the ideal would be to have a "ftransformed"
(or with some other name), and then just define a function (as fun in
the example below), and then be able to do "draw X ftransformed fun;",
where X is some(any?) general object. Is that doable?
...
endfor
So, yes, easy to write a primary (but I don't like the name
"ftransformed"). Using lua helpers can make this efficient.
OK, looping through the pic sounds like a good idea. The word
ftransformed was made up while writing the email, and I agree it is
not good (perhaps "mapped" is better). I trust that you will come up
with something that fits well.
Post by Alan Braslau
Alan
Yet another wish:

3) It would be nice to be able to plot some special functions. I'm
thinking of the usual suspects, Airy, Bessel, Hypergeometric,
Laguerre, Legendre, ... Could it be that one could have support via
some lua library?

/Mikael
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-***@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
____________________________________________
Alan Braslau
2018-12-08 15:15:20 UTC
Permalink
On Sat, 8 Dec 2018 09:31:46 +0100
Post by Mikael P. Sundqvist
3) It would be nice to be able to plot some special functions. I'm
thinking of the usual suspects, Airy, Bessel, Hypergeometric,
Laguerre, Legendre, ... Could it be that one could have support via
some lua library?
I use ffi and libcerf (thank you Luigi!)
For example (lots of other functions are available):

\startluacode

ffi = require("ffi")
ffi.cdef[[
double j0(double x);
double j1(double x);
double jn(double x);
]]

cerf = ffi.load(ffi.os == "OSX" and "/opt/local/lib/libcerf.dylib" or "cerf")

\stopluacode

\startMPdefinitions {doublefun}

vardef jzero primary x = scantokens(lua("mp.quoted( ffi.C.j0(" & decimal x & "))")) enddef ;
vardef jone primary x = scantokens(lua("mp.quoted( ffi.C.j1(" & decimal x & "))")) enddef ;
vardef jn primary x = scantokens(lua("mp.quoted( ffi.C.jn(" & decimal x & "))")) enddef ;

\stopMPdefinitions
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-***@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
_____________________________________________________________________
Continue reading on narkive:
Loading...