/usr/src/castle-game-engine-4.1.1/base/castlevectors_operators_vector_implementation.inc is in castle-game-engine-src 4.1.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 | { Implement vector operators.
Copied and adjusted from FPC's rtl/inc/mvecimp.inc }
{*****************************************************************************
Vector to vector operations
*****************************************************************************}
operator + (const x,y:objectname) : objectname;
{Adds the elements of both vectors together.}
begin
result[0]:=x[0]+y[0];
result[1]:=x[1]+y[1];
{$if vecsize>=3}
result[2]:=x[2]+y[2];
{$endif}
{$if vecsize>=4}
result[3]:=x[3]+y[3];
{$endif}
end;
operator - (const x:objectname) : objectname;
{Negates the elements of a vector.}
begin
result[0]:=-x[0];
result[1]:=-x[1];
{$if vecsize>=3}
result[2]:=-x[2];
{$endif}
{$if vecsize>=4}
result[3]:=-x[3];
{$endif}
end;
operator - (const x,y:objectname) : objectname;
{Subtracts the elements of both vectors together.}
begin
result[0]:=x[0]-y[0];
result[1]:=x[1]-y[1];
{$if vecsize>=3}
result[2]:=x[2]-y[2];
{$endif}
{$if vecsize>=4}
result[3]:=x[3]-y[3];
{$endif}
end;
operator * (const x,y:objectname) : objectname;
{Multiplies the elements of two vectors.}
begin
result[0]:=x[0]*y[0];
result[1]:=x[1]*y[1];
{$if vecsize>=3}
result[2]:=x[2]*y[2];
{$endif}
{$if vecsize>=4}
result[3]:=x[3]*y[3];
{$endif}
end;
{$ifndef CASTLEVECTOR_OPERATOR_ON_INTEGERS}
operator / (const x,y:objectname) : objectname;
{Divides the elements of two vectors.
In most cases, you will want to avoid this and multiply by the inverse.
In case you need to preserve accuracy, dividing might be better though.}
begin
result[0]:=x[0]/y[0];
result[1]:=x[1]/y[1];
{$if vecsize>=3}
result[2]:=x[2]/y[2];
{$endif}
{$if vecsize>=4}
result[3]:=x[3]/y[3];
{$endif}
end;
{$endif CASTLEVECTOR_OPERATOR_ON_INTEGERS}
operator ** (const x,y:objectname) : datatype;
{Calculates the inproduct of two vectors.}
begin
result:=x[0]*y[0]
+x[1]*y[1]
{$if vecsize>=3}+x[2]*y[2]{$endif}
{$if vecsize>=4}+x[3]*y[3]{$endif};
end;
{$if vecsize=3}
operator >< (const x,y:objectname) : objectname;
{Calculates the exproduct of two vectors. The exproduct exists only for
3-dimensional vectors}
begin
result[0]:=x[1]*y[2]-x[2]*y[1];
result[1]:=x[2]*y[0]-x[0]*y[2];
result[2]:=x[0]*y[1]-x[1]*y[0];
end;
{$endif}
{*****************************************************************************
Vector/scalar operations
*****************************************************************************}
operator * (const x:objectname;y:datatype) : objectname;
{Multiplies all vector elements by a scalar.}
begin
result[0]:=x[0]*y;
result[1]:=x[1]*y;
{$if vecsize>=3}
result[2]:=x[2]*y;
{$endif}
{$if vecsize>=4}
result[3]:=x[3]*y;
{$endif}
end;
{$ifndef CASTLEVECTOR_OPERATOR_ON_INTEGERS}
operator / (const x:objectname;y:datatype) : objectname;
{Divides all vector elements by a scalar.}
begin
result[0]:=x[0]/y;
result[1]:=x[1]/y;
{$if vecsize>=3}
result[2]:=x[2]/y;
{$endif}
{$if vecsize>=4}
result[3]:=x[3]/y;
{$endif}
end;
{$endif CASTLEVECTOR_OPERATOR_ON_INTEGERS}
|