!******************************************** BASIC GEOMETRY MODULE diacur( REF cur_id >"@t8 Select curve !"; VECTOR zlevel >"Lower level of diagram !"; FLOAT y1:=15 >"Start Y-value !"; FLOAT x2:=5000 >"Intermediate X-value !"; FLOAT y2:=0 >"Intermediate Y-value !"; FLOAT y3:=10 >"End Y-value !"; STRING name*132:="Angle" >"Name of Y-axis !"; FLOAT ysize:=2000); ! Actual size of diagram in Y-direction !* Creates a curve #1 of equal length to the !* input curve by interpolating 3 positions. !* !* This program is free software; you can redistribute it and/or !* modify it under the terms of the GNU General Public License !* as published by the Free Software Foundation; either version 2 !* of the License, or (at your option) any later version. !* !* This program is distributed in the hope that it will be useful, !* but WITHOUT ANY WARRANTY; without even the implied warranty of !* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the !* GNU General Public License for more details. !* !* You should have received a copy of the GNU General Public License !* along with this program; if not, write to the Free Software !* Foundation, Inc., 59 Temple Place - Suite 330, Boston, !* MA 02111-1307, USA. !* !* (C)Microform AB 1999-01-13, J.Kjellander !* !******************************************** VECTOR p1,p2; FLOAT cl,ymax,ymin,yrange,ysize_user; BEGINMODULE !* !***How long is the input curve in the X-direction ? !***This controls the size of the diagram in the !***X-direction. !* cur_id:=global_ref(cur_id,9); p1:=startp(cur_id); p2:=endp(cur_id); cl:=abs(p1.x-p2.x); !* !***Draw outline of the diagram with text. !* csys_1p(#10,name,vec(p2.x,0,zlevel.z),-90,0,0:BLANK=1); mode_local(#10); set(TSIZE=ysize/10,TSLANT=0,TWIDTH=45); lin_free(#11,vec(0,0),vec(cl,0)); lin_offs(#12,#11,-ysize); lin_free(#13,startp(#11),startp(#12)); lin_free(#14,endp(#11),endp(#12)); text(#15,vec(-0.02*cl,0),90,name); !* !***The max and min values in the Y-direction. !* ymax:=y1; if y2 > ymax then ymax:=y2; endif; if y3 > ymax then ymax:=y3; endif; ymin:=y1; if y2 < ymin then ymin:=y2; endif; if y3 < ymin then ymin:=y3; endif; !* !***The range in user Y that is mapped to ysize. !* yrange:=ymax-ymin; !* !***If the curve is a straight horisontal line !***yrange = 0. Then set ysize_user to something !***sensible. !* if abs(yrange) < 0.01 then yrange:=0.0; ysize_user:=2*abs(ymin); text(#20,vec(1.02*cl,ysize/2),0,str(ymin,-1,1)); !* !***If not create texts for min and max Y-values. !* else ysize_user:=yrange; text(#16,endp(#11)+vec(0.02*cl,0),0,str(ymin,-1,1)); text(#17,endp(#12)+vec(0.02*cl,0),0,str(ymax,-1,1)); endif; !* !***If ymax and ymin have different signs, draw Y=0. !* if ymax > 0 and ymin < 0 then lin_offs(#18,#11,-abs(ymin)/yrange*ysize); text(#19,endp(#18)+vec(0.02*cl,0),0,"0"); endif; !* !***Draw 3 red points. !* set(PEN=2); if yrange = 0.0 and ymin >= 0.0 then ymin:=0; elif yrange = 0.0 then ymin:=-ysize_user; endif; poi_free(#30,vec(-1,(y1-ymin)/ysize_user*ysize)); poi_free(#31,vec(x2,(y2-ymin)/ysize_user*ysize)); poi_free(#32,vec(cl+1,(y3-ymin)/ysize_user*ysize)); !* !***Create the actual curve. !* cur_spline(#1,"FREE",on(#30),vec(0,0),on(#31),vec(0,0),on(#32)); ENDMODULE !********************************************