@@ -129,7 +129,8 @@ pub trait CoordinateSet: CoordinateMetadata {
129
129
/// Number of coordinate tuples in the set
130
130
fn len ( & self ) -> usize ;
131
131
132
- /// Native dimension of the underlying coordinates (they will always be returned as converted to [`Coor4D`](super::Coor4D))
132
+ /// Native dimension of the underlying coordinates (they will always be
133
+ /// returned by [`Self::get_coord()`] as converted to [`Coor4D`](super::Coor4D))
133
134
fn dim ( & self ) -> usize ;
134
135
135
136
/// Access the `index`th coordinate tuple
@@ -147,22 +148,55 @@ pub trait CoordinateSet: CoordinateMetadata {
147
148
/// with `x` and `y`.
148
149
/// Consider providing a type specific version, when implementing
149
150
/// the CoordinateSet trait for a concrete data type: The default
150
- /// version is straightforward, but not very efficient.
151
+ /// version is straightforward, but not necessarily efficient
151
152
fn set_xy ( & mut self , index : usize , x : f64 , y : f64 ) {
152
153
let mut coord = self . get_coord ( index) ;
153
- coord. set_nth_unchecked ( 0 , x ) ;
154
- coord. set_nth_unchecked ( 1 , y ) ;
154
+ coord[ 0 ] = x ;
155
+ coord[ 1 ] = y ;
155
156
self . set_coord ( index, & coord) ;
156
157
}
157
158
158
159
/// Access the two first elements of the `index`th `CoordinateTuple`.
159
160
/// Consider providing a type specific version, when implementing
160
161
/// the CoordinateSet trait for a concrete data type: The default
161
- /// version is straightforward, but not very efficient.
162
+ /// version is straightforward, but not necessarily efficient
162
163
fn xy ( & self , index : usize ) -> ( f64 , f64 ) {
163
164
self . get_coord ( index) . xy ( )
164
165
}
165
166
167
+ /// Replace the three first elements of the `index`th `CoordinateTuple`
168
+ /// with `x`, `y` and `z`.
169
+ /// Consider providing a type specific version, when implementing
170
+ /// the CoordinateSet trait for a concrete data type: The default
171
+ /// version is straightforward, but not necessarily efficient
172
+ fn set_xyz ( & mut self , index : usize , x : f64 , y : f64 , z : f64 ) {
173
+ let mut coord = self . get_coord ( index) ;
174
+ coord[ 0 ] = x;
175
+ coord[ 1 ] = y;
176
+ coord[ 2 ] = z;
177
+ self . set_coord ( index, & coord) ;
178
+ }
179
+
180
+ /// Access the three first elements of the `index`th `CoordinateTuple`.
181
+ /// Consider providing a type specific version, when implementing
182
+ /// the CoordinateSet trait for a concrete data type: The default
183
+ /// version is straightforward, but not necessarily efficient
184
+ fn xyz ( & self , index : usize ) -> ( f64 , f64 , f64 ) {
185
+ self . get_coord ( index) . xyz ( )
186
+ }
187
+
188
+ /// Replace the four elements of the `index`th `CoordinateTuple`
189
+ /// with `x`, `y`, `z` and `t`. Syntactic sugar for [`Self::set_coord`]
190
+ fn set_xyzt ( & mut self , index : usize , x : f64 , y : f64 , z : f64 , t : f64 ) {
191
+ self . set_coord ( index, & Coor4D ( [ x, y, z, t] ) ) ;
192
+ }
193
+
194
+ /// Access the four elements of the `index`th `CoordinateTuple`.
195
+ /// Syntactic sugar for [`Self::get_coord`]
196
+ fn xyzt ( & self , index : usize ) -> ( f64 , f64 , f64 , f64 ) {
197
+ self . get_coord ( index) . xyzt ( )
198
+ }
199
+
166
200
/// Set all coordinate tuples in the set to NaN
167
201
fn stomp ( & mut self ) {
168
202
let nanny = Coor4D :: nan ( ) ;
0 commit comments