| 1 | /******************************************************************************* |
|---|
| 2 | * |
|---|
| 3 | * McStas, neutron ray-tracing package |
|---|
| 4 | * Copyright 1997-2002, All rights reserved |
|---|
| 5 | * Risoe National Laboratory, Roskilde, Denmark |
|---|
| 6 | * Institut Laue Langevin, Grenoble, France |
|---|
| 7 | * |
|---|
| 8 | * Kernel: coords.c |
|---|
| 9 | * |
|---|
| 10 | * %Identification |
|---|
| 11 | * Written by: K.N. |
|---|
| 12 | * Date: Aug 8, 1997 |
|---|
| 13 | * Origin: Risoe |
|---|
| 14 | * Release: McStas 1.6 |
|---|
| 15 | * Version: $Revision: 1.16 $ |
|---|
| 16 | * |
|---|
| 17 | * Misc. useful routines to handle Cartesian coordinates. |
|---|
| 18 | * |
|---|
| 19 | * $Id: coords.c,v 1.16 2006-04-19 13:06:25 farhi Exp $ |
|---|
| 20 | * |
|---|
| 21 | * $Log: coords.c,v $ |
|---|
| 22 | * Revision 1.16 2006-04-19 13:06:25 farhi |
|---|
| 23 | * * Updated Release, Version and Origin fields in headers |
|---|
| 24 | * * Improved setversion to update all McStasx.y occurencies into current release |
|---|
| 25 | * * Added 'string' type for DEFINITION parameters to be handled as this type so that auto-quoting occurs in mcgui |
|---|
| 26 | * * Added possibility to save log of the session to a file (appended) in mcgui |
|---|
| 27 | * * Made Scilab use either TCL_EvalStr or TK_EvalStr |
|---|
| 28 | * |
|---|
| 29 | * Revision 1.15 2003/02/11 12:28:45 farhi |
|---|
| 30 | * Variouxs bug fixes after tests in the lib directory |
|---|
| 31 | * mcstas_r : disable output with --no-out.. flag. Fix 1D McStas output |
|---|
| 32 | * read_table:corrected MC_SYS_DIR -> MCSTAS define |
|---|
| 33 | * monitor_nd-lib: fix Log(signal) log(coord) |
|---|
| 34 | * HOPG.trm: reduce 4000 points -> 400 which is enough and faster to resample |
|---|
| 35 | * Progress_bar: precent -> percent parameter |
|---|
| 36 | * CS: ---------------------------------------------------------------------- |
|---|
| 37 | * |
|---|
| 38 | * Revision 1.3 2000/07/27 09:06:11 kn |
|---|
| 39 | * Changed argument of exp_number() from 0 to "0.0". |
|---|
| 40 | * |
|---|
| 41 | * Revision 1.2 1998/10/02 08:36:05 kn |
|---|
| 42 | * Fixed header comment. |
|---|
| 43 | * |
|---|
| 44 | * Revision 1.1 1997/08/13 09:13:18 kn |
|---|
| 45 | * Initial revision |
|---|
| 46 | * |
|---|
| 47 | *******************************************************************************/ |
|---|
| 48 | |
|---|
| 49 | #include "mcstas.h" |
|---|
| 50 | |
|---|
| 51 | /******************************************************************************* |
|---|
| 52 | * Since we use a lot of geometric calculations using Cartesian coordinates, |
|---|
| 53 | * we collect some useful routines here. However, it is also permissible to |
|---|
| 54 | * work directly on the underlying struct coords whenever that is most |
|---|
| 55 | * convenient (that is, the type Coords is not abstract). |
|---|
| 56 | * |
|---|
| 57 | * Coordinates are also used to store rotation angles around x/y/z axis. |
|---|
| 58 | * |
|---|
| 59 | * Since coordinates are used much like a basic type (such as double), the |
|---|
| 60 | * structure itself is passed and returned, rather than a pointer. |
|---|
| 61 | * |
|---|
| 62 | * At compile-time, the values of the coordinates may be unknown (for example |
|---|
| 63 | * a motor position). Hence coordinates are general expressions and not simple |
|---|
| 64 | * numbers. For this we used the type Coords_exp which has three CExp |
|---|
| 65 | * fields. For runtime (or calculations possible at compile time), we use |
|---|
| 66 | * Coords which contains three double fields. |
|---|
| 67 | *******************************************************************************/ |
|---|
| 68 | |
|---|
| 69 | Coords_exp coords_exp_origo(void) |
|---|
| 70 | { |
|---|
| 71 | Coords_exp c; |
|---|
| 72 | |
|---|
| 73 | c.x = exp_number("0.0"); |
|---|
| 74 | c.y = exp_number("0.0"); |
|---|
| 75 | c.z = exp_number("0.0"); |
|---|
| 76 | return c; |
|---|
| 77 | } |
|---|