# Users Manual for Program KPF_ROT

Program KPF_ROT reads data from INFIL and rotates the profile an angle FIR or translates the profile the distance YH. N.B. only one command of FIR or YH can be given in input data. If neither FIR and YH are defined in input data, program KPF_ROT will just orient INFIL according to YAXIS and ZAXIS, and write the result to UTFIL.

The calculation of the new profile is carried out in the following way:

• Read X-, Y- values from INFIL.
• Orient the axes according to YAXIS and ZAXIS.
• Scale the values according to the commands INFIL_SCALE_Y and INFIL_SCALE_Z.
• Remove all nodes that make backsteps in the Y-direction.
• If, YH has been given in input data, the program will do the following:
• Shift the profile laterally the distance YH.
• Make a dense interpolation in a coordinate system rotated the angle FI_SLANT.
• Make an interpolation in the vertical/horizontal plane, in order to get equidistant steps in Y-direction.
• Adjust the profile vertically in order to move origin to the surface of the profile: z(y=0.)= 0.
• Elseif, FIR has been given in input data, the program will do the following:
• Rotate the profile angle FIR.
• Make a dense interpolation in a coordinate system rotated the angle FI_SLANT.
• Find T.o.R. (top of rail)
• Find the Gauge Measuring Point between Top of Rail and GAUGE_MEAS_INTERVAL beneath.
• Do
• Shift the profile laterally in order to locate origin the distance GAUGE_TO_ORIGO from the Gauge Measuring Point
• Adjust the profile vertically in order to move origin to the surface of the profile: z(y=0.)= 0.
Until "The two points T.o.R. and Gauge Measuring Point are positioned within a tolerance of 1.e-7"
• Make an interpolation in the vertical/horizontal plane, in order to get equidistant steps in Y-direction.
• Else
• Make a dense spline interpolation in a coordinate system rotated angle FI_SLANT.
• Make an interpolation in the vertical/horizontal plane, in order to get equidistant steps in Y-direction.
• Endif
• Write the result to UTFIL.

## INPUT DATA

Input data are written in free format:

Adjustment of origin after rotating or translating the profile. ADJUST_ZERO may have the following values:
 yes = The output profile will be zero-adjusted no = No zero adjustments will take place
Declared= Character*4    Default= 'yes'

DY
Lateral equdistant steps on file UTFIL [mm].
Declared= Real(8)    Default= 0.02 [mm]

FI_SLANT
Angle in which the profile is slanted in when making spline interpolations, to make it more easier for the splines to handle very sharp gauge corners on rail profiles.
Declared= Real(8)    Default= 0.35

GAUGE_MEAS_INTERVAL
Vertical interval relative to Top of Rail when finding the Gauge Measuring Point. This point is a point on the rail that is closest to the track center line, and is located on the surface of the rail between Top of Rail and GAUGE_MEAS_INTERVAL beneath.
Declared= Real(8)    Default= 14. [mm]

GAUGE_TO_ORIGO
Defines the lateral distance from Gauge Measuring Point to Origin rail (the location of the nominal running circle)
Declared= Real(8)    Default= 32.5[mm]

INFIL
Input data file.
Declared= Character*132    Default= Blank

INFIL_SCALE_Y
Scale first column in INFIL to get data in [mm].
Declared= Real(8)    Default= 1.

INFIL_SCALE_Z
Scale second column in INFIL to get data in [mm].
Declared= Real(8)    Default= 1.

SPL_INTPL
Spline interpolation close to nodes in INFIL.
The measurements of wheel and rail profiles are often a bit coarse. Linear interpolation doesn't work well because that creates facets on the profiles. Spline interpolation doesn't also work well because it may create ringing in between the nodes. Therefore program kpf_rot interpolates the profiles with a combination of linear and spline interpolation. Spline interpolation is performed close to each node. Linear interpolation is performed on the straight sections in between the nodes. In the SPL_INTPL command, the user has the possibility to define the length from the node to the start of the spline interpolation. If the value of SPL_INTPL is positive, the length of the spline interpolation is absolute. If the value of SPL_INTPL is negative, the length of the spline interpolation is relative. Using a negative value is advantageous if the nodes in INFIL not are equdistant spaced.
Declared= Real(8)    Default= -0.75

UTFIL
Output data file.
Declared= Character*132    Default= Blank

FIR
Rotational angle, positive value gives a right handed rotation.

YH
Lateral translation of the profile, positive value gives larger gauge.
Declared= Real(8)    Default= 0.[mm]

YAXIS
Orientation of the Y-axis. YAXIS may be given the following values:
 1 => Read Y-axis is used as Y-axis. -1 => Read Y-axis is used as Y-axis, but with reversed sign. 2 => Read Z-axis is used as Y-axis. -2 => Read Z-axis is used as Y-axis, but with reversed sign.
Declared= Real(8)    Default= 1

ZAXIS
Orientation of the Z-axis. ZAXIS may be given the following values:
 1 => Read Y-axis is used as Z-axis. -1 => Read Y-axis is used as Z-axis, but with reversed sign. 2 => Read Z-axis is used as Z-axis. -2 => Read Z-axis is used as Z-axis, but with reversed sign.
Declared= Real(8)    Default= 1

## Example of an input data file

Following example: Master.kpf_rotf can be used as a master file:

```##
##      Input data for program "kpf_rot"
##

# INFIL= \$genkpf/../w_prof/S1002/S1002.wheel   # Reading wheel profile
# UTFIL= S1002.kpf_rotr

INFIL= \$genkpf/../r_prof/uic60/uic60i00.rail # Reading rail profile
UTFIL= uic60i40.kpf_rotr

YAXIS = 1  # Use the first column on INFIL as Y-axis
# YAXIS =-1  # Use the first column on INFIL as Y-axis, but with reversed sign.
ZAXIS = 2  # Use the second column on INFIL as Z-axis
# ZAXIS =-2  # Use the second column on INFIL as Z-axis, but with reversed sign.

INFIL_SCALE_Y= 1   # Scale first column in INFIL to get data in [mm]
INFIL_SCALE_Z= 1   # Scale second column in INFIL to get data in [mm]

SPL_INTPL= -.75    # Length of spline interpolation near nodes
DY      = 0.02     # Lateral equdistant steps on file UTFIL [mm]
FI_SLANT= 0.35     # Slant angle in which the interpolation will take place

##
##      Define operation to be applied to the profile
##      N.B.: only one of YH and FIR can be given.
##      YH  refers to a lateral shift of the wheel profile
##      FIR rotates the rail profile and zero sets the origin of the rail profile

##
##      Input data regarding wheel profiles
##      -----------------------------------------------------------
# YH  =  1.0     # Translate the profile +1 mm to simulate a thinner flange

##
##      Input data regarding rail profiles
##      -----------------------------------------------------------
# FIR=  0.                 # No rotation
FIR= `atan(1/40)`        # Rotatate profile to 1/40 inclination
# FIR= `atan(1/30)`        # Rotatate profile to 1/30 inclination
# FIR= `atan(1/20)`        # Rotatate profile to 1/20 inclination
#
ADJUST_ZERO = yes        # After rotation zero set the origin of the profile
GAUGE_TO_ORIGO= 32.5     # Distance between origin of the rail
# and the Gauge Measuring Point.
GAUGE_MEAS_INTERVAL= 14  # Vertical interval from Top-of-Rail when
# finding the Gauge Measuring Point.
```