 |
forums.silverfrost.com Welcome to the Silverfrost forums
|
View previous topic :: View next topic |
Author |
Message |
sospel
Joined: 26 Apr 2013 Posts: 31
|
Posted: Sat Jul 13, 2013 1:32 pm Post subject: What choice for drawing curves ? |
|
|
Hello !
I would need an advice
Here is my problem :
I calculate some comets trajectories and I would want to make them draw in 1 or 2 window which I open on the screen, with a length and a width given, a given thorough color, a given title, and every trajectory drawn point by point, of a given color.
My problem is this one: I have well the graphic software SIMFIT, SIMDEM , CLEARWIN+ and OPENGL in SILVERFROST package but " there is too much "
and I don't know which to use ....
Could one of you recommend me on the best way to begin ? Especially also because after the plan of comets, I would like to draw the "chaotic" trajectories which aim towards the strange attractors ...
Thank you in advance !!
Cordially,
Sospel |
|
Back to top |
|
 |
DanRRight
Joined: 10 Mar 2008 Posts: 2923 Location: South Pole, Antarctica
|
Posted: Sat Jul 13, 2013 8:26 pm Post subject: |
|
|
Post a link on example of what you'd ideally wanted to see? |
|
Back to top |
|
 |
LitusSaxonicum
Joined: 23 Aug 2005 Posts: 2402 Location: Yateley, Hants, UK
|
Posted: Sat Jul 13, 2013 10:35 pm Post subject: |
|
|
Sospel,
If your points on the comet trajectory are close enough to each other, you can just draw straight lines between them and it will look like a curve onscreen. When they are too far apart, you need to interpolate more points. As a comet trajectory is a conic section, you should be able to interpolate positions using a parabola over a short enough segment (or a hyperbola if you are fussy), and calculate enough extra points to give a smooth curve appearance when you join the points with straight lines! You can fit a parabola through any 3 points. Do it all with Clearwin+ graphics. Comets don't change direction suddenly (at least while they don't hit planets full of dinosaurs), so the trajectory curves must be gradual. I've drawn lots of curves this way, usually circles or circular arcs, and they look fine.
Eddie |
|
Back to top |
|
 |
sospel
Joined: 26 Apr 2013 Posts: 31
|
Posted: Sun Jul 14, 2013 8:22 pm Post subject: What choice for drawing curves ? |
|
|
Hello @ DanRRight and LitusSaxonicum
Thank you for your answers.
In reality, I wished to have a "global" advice on the graphics softwares to choose the one who is the easiest to use for many graphs : trajectories of comets, but also trajectories of "mathematical objects " such as those converging on a strange attractor, or Julia's " curves " or Mandelbrot "fractals" ...
I think that LitusSaxonicum suggests with good reason to using CLEARWIN+ : I browsed the notice and I have effectively the feeling that I can open several windows simultaneously, to study for example the influence of certain parameters.
I have moreover just found in the directory of CLEARWIN an example of program which corresponds about to the fact that I wish to make : "PLOTFUNC.F95" . It is short and very easy to modify : I am going to be inspired by it to begin my graphs !!
Thus, thank you again, and see you soon for other advice
Cordially
Sospel  |
|
Back to top |
|
 |
LitusSaxonicum
Joined: 23 Aug 2005 Posts: 2402 Location: Yateley, Hants, UK
|
Posted: Mon Jul 15, 2013 2:55 pm Post subject: |
|
|
PLOTFUNC makes use of SimplePlot, and elsewhere in the forum you will learn that this is no longer supported. Even a few years ago I decided not to use it because of that, but (despite a few issues with modern versions of Windows) it appears to still work, and to have some really nice features.
I always draw my own stuff from the simple primitives in FTN95/Clearwin+. Here is a simple and rough program to show you how to draw 2 separate graphics areas in one Window (but you could have several free-floating windows as well):
Code: | WINAPP
OPTIONS (INTL)
PROGRAM CURVES
IMPLICIT DOUBLE PRECISION (A-H, O-Z)
INCLUDE <WINDOWS.INS>
EXTERNAL WIN1_FN, WIN2_FN, DRAW_FN
COMMON / COORDINATES1 / AX(200), AY(200)
COMMON / COORDINATES2 / BX(200), BY(200)
COMMON / GRAPH_HANDLES/ iGR1, iGR2
iGR1=98; iGR2=99
CALL SET_COORDS
IA=WINIO@('%ca[Two curves program]&')
IA=WINIO@('%sy[3d_thin]&')
IA=WINIO@('%mn[File[Exit],Draw[Window1,Window2]]&','EXIT',
& WIN1_FN, WIN2_FN)
IA=WINIO@('%`gr[red]&', 200, 200, iGR1)
IA=WINIO@('%ta%`gr[blue]', 200, 200, iGR2)
END
SUBROUTINE SET_COORDS
IMPLICIT DOUBLE PRECISION (A-H, O-Z)
COMMON / COORDINATES1 / AX(200), AY(200)
COMMON / COORDINATES2 / BX(200), BY(200)
DO 10 I=1,200
AX(I) = 0.0D0 + (I-1)*1.0D0
10 CONTINUE
BX = AX
DO 20 I=1,200 ! arbitrary functions here so something to draw
AY(I) = 0.01*AX(I)**2-0.02*AX(I)+50.0
BY(I) = -0.02*AX(I)**2+0.01*AX(I)-17.0
20 CONTINUE
END
INTEGER FUNCTION WIN1_FN()
IMPLICIT DOUBLE PRECISION (A-H, O-Z)
COMMON / COORDINATES1 / AX(200), AY(200)
COMMON / GRAPH_HANDLES/ iGR1, iGR2
INCLUDE <WINDOWS.INS>
COMMON /PIXELS/ IX(200), IY(200)
XBIG = AX(1); XSMALL = AX(1)
YBIG = AY(1); YSMALL = AY(1)
DO 10 I=2,200
XBIG=MAX(AX(I),XBIG); XSMALL=MIN(AX(I),XSMALL)
YBIG=MAX(AY(I),YBIG); YSMALL=MIN(AY(I),YSMALL)
10 CONTINUE
XSCALE = (XBIG-XSMALL)/200
YSCALE = (YBIG-YSMALL)/200
DO 20 I=1,200
IX(I)=(AX(I)-XSMALL)/XSCALE; IY(I)=(YBIG-AY(I))/YSCALE
20 CONTINUE
IB=SELECT_GRAPHICS_OBJECT@ (iGR1)
IB=USE_RGB_COLOURS@ (iGR1, .TRUE.)
CALL DRAW_FILLED_RECTANGLE@ (0, 0, 199, 199, RGB@(0,0,0))
CALL GRID
CALL DRAW_POLYLINE@ (IX, IY, 200, RGB@(255, 255, 255))
WIN1_FN = 1
END |
Last edited by LitusSaxonicum on Mon Jul 15, 2013 2:59 pm; edited 2 times in total |
|
Back to top |
|
 |
LitusSaxonicum
Joined: 23 Aug 2005 Posts: 2402 Location: Yateley, Hants, UK
|
Posted: Mon Jul 15, 2013 2:57 pm Post subject: |
|
|
Code: | INTEGER FUNCTION WIN2_FN()
IMPLICIT DOUBLE PRECISION (A-H, O-Z)
COMMON / COORDINATES2 / BX(200), BY(200)
COMMON / GRAPH_HANDLES/ iGR1, iGR2
COMMON /PIXELS/ IX(200), IY(200)
INCLUDE <WINDOWS.INS>
XBIG = BX(1); XSMALL = BX(1)
YBIG = BY(1); YSMALL = BY(1)
DO 10 I=2,200
XBIG=MAX(BX(I),XBIG); XSMALL=MIN(BX(I),XSMALL)
YBIG=MAX(BY(I),YBIG); YSMALL=MIN(BY(I),YSMALL)
10 CONTINUE
XSCALE = (XBIG-XSMALL)/200
YSCALE = (YBIG-YSMALL)/200
DO 20 I=1,200
IX(I)=(BX(I)-XSMALL)/XSCALE; IY(I)=(YBIG-BY(I))/YSCALE
20 CONTINUE
IB=SELECT_GRAPHICS_OBJECT@ (iGR2)
IB=USE_RGB_COLOURS@ (iGR2, .TRUE.)
CALL DRAW_FILLED_RECTANGLE@ (0, 0, 199, 199, RGB@(255,255,255))
CALL GRID
CALL DRAW_POLYLINE@ (IX, IY, 200, RGB@(255, 0, 0))
WIN2_FN = 1
END
SUBROUTINE GRID
INCLUDE <WINDOWS.INS>
CALL DRAW_LINE_BETWEEN@ (0, 149, 199, 149, RGB@(0,0,255))
CALL DRAW_LINE_BETWEEN@ (0, 99, 199, 99, RGB@(0,0,255))
CALL DRAW_LINE_BETWEEN@ (0, 49, 199, 49, RGB@(0,0,255))
CALL DRAW_LINE_BETWEEN@ (49, 0, 49, 199, RGB@(0,0,255))
CALL DRAW_LINE_BETWEEN@ (99, 0, 99, 199, RGB@(0,0,255))
CALL DRAW_LINE_BETWEEN@ (149, 0, 149, 199, RGB@(0,0,255))
END |
(And it really irritates me that the Preview works, and the post is truncated!) |
|
Back to top |
|
 |
Kenneth_Smith
Joined: 18 May 2012 Posts: 814 Location: Hamilton, Lanarkshire, Scotland.
|
Posted: Mon Jul 15, 2013 6:10 pm Post subject: |
|
|
I've played about with Clearwin+ and found it very useful, although a difficult to (initially) get my head round some of the programing concepts. The drawing space in the graphics region being in the 4th quadrant caused me a fair bit of grief in the beginning!
However, I'd recommend you give it a go, Clearwin+ has allowed me to do things where other plotting tools have failed.
The following is an example of what's possible with just a few lines of code:-
http://www.avao.co.uk/plot.bmp
Cheers
Ken |
|
Back to top |
|
 |
LitusSaxonicum
Joined: 23 Aug 2005 Posts: 2402 Location: Yateley, Hants, UK
|
Posted: Mon Jul 15, 2013 7:21 pm Post subject: |
|
|
Having Y increase downwards also confused me to begin with. I use the following two statement functions to convert to pixels:
Code: | IPOSX(XX) = (XX-CENTRE_X)/SCREEN_SCALE+IXRES/2
IPOSY(YY) = IYRES/2-(YY-CENTRE_Y)/SCREEN_SCALE |
CENTRE_X and CENTRE_Y are the coordinates of the mid point of the object in real world coordinates, IXRES and IYRES the pixels in X and Y, and SCREEN_SCALE is the number of pixels per real world unit. (My objects are always drawn to true aspect ratio). If the �fit to screen� option is chosen, you work out SCREEN_SCALE in both directions, and choose the largest. Zooming in is a matter of changing SCREEN_SCALE and redrawing, panning is a matter of changing CENTRE_X and/or CENTRE_Y.
When picking an object from a mouse click, the real world x and y coordinates are obtained with the inverse of these formulae, e.g.
Code: | REAL_WORLD_X(IPIXEL_X) = (IPIXEL_X-IXRES/2)*SCRN_SCALE + CENTRE_X
REAL_WORLD_Y(IPIXEL_Y) = CENTRE_Y - (IPIXEL_Y-IYRES/2)*SCRN_SCALE |
In this case you may need to round the real world coordinates, or you may get many decimal places of inaccuracy.
Since I started using these I have forgotten about y increases downwards....
Eddie |
|
Back to top |
|
 |
JohnCampbell
Joined: 16 Feb 2006 Posts: 2615 Location: Sydney
|
Posted: Tue Jul 16, 2013 1:42 am Post subject: |
|
|
Ken,
An interesting plot.
You appear to have the same problem as I do of trying to get a rainbow palette where the displayed colours are visually differentiated, especially in the greens.
It would be good to get an algorithm that can give a rainbow of colours, with even perception of colour difference. Using a uniform numerical difference in the RGB numbers does not give a good solution.
John |
|
Back to top |
|
 |
Kenneth_Smith
Joined: 18 May 2012 Posts: 814 Location: Hamilton, Lanarkshire, Scotland.
|
Posted: Tue Jul 16, 2013 7:21 am Post subject: |
|
|
John,
It is indeed a problem, especially with the green part of the spectrum - for a while i thought it was just my eyesight.
The basic algorithim i use is as follows:-
Code: |
!--------------------------------------------------------------------
!
! SUBROUTINE ANGLE_TO_RGB
!
!--------------------------------------------------------------------
!
! ANGLE_TO_RGB returns a colour on the perimeter of the colour
! hexagon.
!
!--------------------------------------------------------------------
SUBROUTINE ANGLE_TO_RGB ( ANGLE_IN, R, G, B )
IMPLICIT NONE
! Inputs
REAL*8, INTENT(IN):: ANGLE_IN
! Outputs
REAL*8, INTENT(OUT):: R, G, B
! Locals
REAL*8 ANGLE, ANGLE2
REAL*8 DEGREES_TO_RADIANS
PARAMETER (DEGREES_TO_RADIANS = 3.141592653589793D+00/180.0D+00)
REAL*8 ZERO, ONE, THREE, FOUR
PARAMETER (ZERO=0.0D0, ONE=1.0D0, THREE=3.0D0, FOUR=4.0D0)
REAL*8 K60, K120, K180, K240, K300, K360
PARAMETER ( K60= 60.D0, K120=120.D0, K180=180.D0)
PARAMETER (K240=240.D0, K300=300.D0, K360=360.0D0)
ANGLE = ANGLE_IN
ANGLE = MOD ( ANGLE, K360 )
IF ( ANGLE .LT. ZERO ) THEN
ANGLE = ANGLE + K360
END IF
IF ( ANGLE .LE. K60 ) THEN
ANGLE2 = THREE * ANGLE / FOUR
ANGLE2 = DEGREES_TO_RADIANS * ANGLE2
R = ONE
G = TAN ( ANGLE2 )
B = ZERO
ELSE IF ( ANGLE .LE. K120 ) THEN
ANGLE2 = THREE * ANGLE / FOUR
ANGLE2 = DEGREES_TO_RADIANS * ANGLE2
R = COS ( ANGLE2 ) / SIN ( ANGLE2 )
G = ONE
B = ZERO
ELSE IF ( ANGLE .LE. K180 ) THEN
ANGLE2 = THREE * ( ANGLE - K120 ) / FOUR
ANGLE2 = DEGREES_TO_RADIANS * ANGLE2
R = ZERO
G = ONE
B = TAN ( ANGLE2 )
ELSE IF ( ANGLE .LE. K240 ) THEN
ANGLE2 = THREE * ( ANGLE - K120 ) / FOUR
ANGLE2 = DEGREES_TO_RADIANS * ANGLE2
R = ZERO
G = COS ( ANGLE2 ) / SIN ( ANGLE2 )
B = ONE
ELSE IF ( ANGLE .LE. K300 ) THEN
ANGLE2 = THREE * ( ANGLE - K240 ) / FOUR
ANGLE2 = DEGREES_TO_RADIANS * ANGLE2
R = TAN ( ANGLE2 )
G = ZERO
B = ONE
ELSE IF ( ANGLE .LE. K360 ) THEN
ANGLE2 = THREE * ( ANGLE - K240 ) / FOUR
ANGLE2 = DEGREES_TO_RADIANS * ANGLE2
R = ONE
G = ZERO
B = COS ( ANGLE2 ) / SIN ( ANGLE2 )
END IF
RETURN
END SUBROUTINE ANGLE_TO_RGB
|
In the plot I posted, regions of high potential are mapped to an angle of zero (red) and low potential are mapped on to 240 deg (blue). To try and overcome the problem with the greens i've applied some "fiddle factors" immediately after the call to the ANGLE_TO_RBG routine.
Code: |
K2=255
DO I = 1, N, 1
CALL ANGLE_TO_RGB (ANGLE, R1, G1, B1)
R(I) = NINT(R1*K2*1.0)
G(I) = NINT(G1*K2*0.5)
B(I) = NINT(B1*K2*0.75)
ZLOOKUP(I) = Z
Z = Z + DZ
ANGLE = ANGLE + ANGLE_STEP
ENDDO
|
These factors are just the result of trial and error. I've tried using the random number generator to generate the factors - but that was not very satisfactory either.
Last edited by Kenneth_Smith on Tue Jul 16, 2013 7:25 am; edited 1 time in total |
|
Back to top |
|
 |
Kenneth_Smith
Joined: 18 May 2012 Posts: 814 Location: Hamilton, Lanarkshire, Scotland.
|
Posted: Tue Jul 16, 2013 7:24 am Post subject: |
|
|
I very much agree with you - it would be good to find a better way to do this. One thought, perhaps having a second "vector" which runs around the colour wheel faster to generate a second set of RGB values, then multiply R(I) from the first vector by R(I) from the second etc. might work. Mathematically this would look something like an amplitude modulating function, with the possibiltiy of varying both the amplitude, phase and frequency of the modulation.
Off to the day job now - which is much less interesting!
Ken |
|
Back to top |
|
 |
LitusSaxonicum
Joined: 23 Aug 2005 Posts: 2402 Location: Yateley, Hants, UK
|
Posted: Tue Jul 16, 2013 9:49 am Post subject: |
|
|
Yes I agree, the rainbow spectrum in the diagram is excellent. The rainbow isn't the only workable 'spectrum', there are others used in geography for example, representing the highest mountains to the deepest oceans. You can also do a single colour (hue) and change its intensity, that gives you less obvious contours.
At a guess, I would say that someone somewhere is very knowledgeable about this!
Eddie |
|
Back to top |
|
 |
Kenneth_Smith
Joined: 18 May 2012 Posts: 814 Location: Hamilton, Lanarkshire, Scotland.
|
Posted: Tue Jul 16, 2013 7:08 pm Post subject: |
|
|
I did a little bit of googling at lunch time as came across this:-
http://paulbourke.net/texture_colour/colourspace/
About 3/4 down the page there is a dicussion "Simple method of storing colour ramps"
There are 22 different "colour ramps" displayed along with a data file for each, containing the 256 different RGB values in each ramp.
Ramp 1 looks very like the output of the ANGLE_TO_RGB subroutine above, which is problematic due to the wide range of the greens. Ramp 16 looks more promising. So I guess some form of interpolation on the corresponding table of data may be useful for some applications. Not exactly an algorithm that can give a rainbow of colours, with even perception of colour difference, that John is looking for, but it might be good enough for some applications?
Ken |
|
Back to top |
|
 |
Kenneth_Smith
Joined: 18 May 2012 Posts: 814 Location: Hamilton, Lanarkshire, Scotland.
|
Posted: Wed Jul 17, 2013 12:05 am Post subject: |
|
|
I took a quick look at the data files for RAMP1 and RAMP16, to see how the individual RGB values vary with position around the colour wheel. RAMP1 is a trapazoidal fuction and RAMP16 is a triangular function - which consequently has the maximum G value for a shorter duration. What's needed is a sort of average between the two, and an offset cosine wave very approximately, fits the bill. Hence:-
Code: |
!--------------------------------------------------------------------
!
! ANGLE_TO_RGB2
!
!--------------------------------------------------------------------
SUBROUTINE ANGLE_TO_RGB2 (THETA,R,G,B)
REAL*8, INTENT(IN)::THETA
REAL*8, INTENT(OUT)::R,G,B
REAL*8 PI
PARAMETER (PI=3.14159265358979323846264338327950288419716939D0)
REAL*8 THETA_L
THETA_L = THETA*PI/180.D0
R = 1.0D0*(COS(THETA_L) + 1.D0)/2.D0
G = 0.9D0*(COS(THETA_L - PI/180.D0*120.D0) + 1.D0)/2.D0
B = 1.0D0*(COS(THETA_L - PI/180.D0*240.D0) + 1.D0)/2.D0
RETURN
END
|
Which produces a good contrast between the different layers without the "fiddle factors" I used earlier.
Examples:-
http://www.avao.co.uk/plot1.png
http://www.avao.co.uk/plot2.png
In both examples the 21 layers are assigned RGB values based on 21 evenly points around the colour wheel from theta = 0 deg (RED) to 240 deg (BLUE).
I hope this is useful.
Cheers Ken |
|
Back to top |
|
 |
DanRRight
Joined: 10 Mar 2008 Posts: 2923 Location: South Pole, Antarctica
|
Posted: Thu Jul 18, 2013 12:39 am Post subject: |
|
|
Code: |
REAL*8 PI
PARAMETER (PI=3.14159265358979323846264338327950288419716939D0)
|
Anyway, after upgrading my PC and overclocking it I just killed 256 bit color option in my program. 256 is dead. 24 bits from now. The OpenGL speedtest shows me 6000+ frames per second (!) and "16 GB RAM is enough for everyone" (parroting copyrighted phrase of Bill Gates who said that about 640K). I suggest everyone forget 256 bit too
As to the ramps, I wrote my own subprogram which makes ANY ramp just by setting few RGB colors for few values of X from 0 to 1. Just two-three or in some cases more X points are required. Program just interpolates between each of 3 RGB points. That damn simple. Can post if you like
When have time i will write Clearwin+ Ramp Designer where you can see the process of ramp creation without typing at all, modify it also just with the mouse and see immediate effect on your plots. And also can grab one you like from someone else just by extracting part of graphics image. You might like some sunset colors on the sky for example, then you just select this part of image, Ctrl+C it and in a microsecond new amazing ramp is ready, just give it a name. I has also copy/paste all or part of ramp, shrink/extend its limits, and of course flip it. That's extremely useful for 2D and 3D plots. If someone has few days for that you are welcome to contribute to Clearwin+ users examples |
|
Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|