I\'m trying to write a program to evenly (or as close to possible) distribute points about the surface of a sphere. I\'m trying to achieve this by placing N points randomly
I've found an answer to my own question
for (point, movement) in points.iter().zip(movements.iter_mut()) {
*movement = Quaternion::identity();
for neighbour in &points {
if neighbour.id == point.id {
continue;
}
let angle = point.pos.angle(&neighbour.pos);
let axis = point.pos.cross(&neighbour.pos);
let force = -(1.0/(angle*angle)) * update_amt;
*movement = (*movement) * Quaternion::angle_axis(angle, axis);
}
}
By creating a separate vector to hold the movements, rather than having movement be a trait of the point, I can borrow the points vector twice as immutable, and borrow the movements vector once as mutable.
I think a C++ mindset still has me thinking too much in terms of classes, but I may still be wrong about this being a ideal way to go about this sort of pattern in rust. If anyone has a problem with this solution, or just knows a better way to go about it, any suggestions would be great.