Mike Burr - log

[math][comp] Triangles 2

[trying to whittle down]

[Dear Chad...]

Please write a program using the rust bevy game engine to do the following:

Start with two points (Vec3) on the Y axis. Point first_point is at y = -1/2 and point second_point is at y = 1/2. These should be mutable variables.

Also define a mutable third_point and set its value to Vec3::ZERO

Define a mutable up = Vec3::Z

Create an array vertices of 20 3-points (Vec3). No values may be 0.0 and they can vary between -1 and 1 inclusive.

Looping over vertices...

Read the first 3-point from the vertices. Use up as +Z and the midpoint between first_point and second_point as the origin, with -Y (left) in the direction of first_point and +Y (right) in the direction of second_point. Assign the coordinate read from vertices to third_point. Note that no translation of coordinates is required for the first pass. The points of interest are the global coordinates for each new point, after coordinate transformations.

For subsequent passes of the loop, use the new values of first_point, second_point and up as the coordinate system in which to interpret third_point.

The three points form a triangle. Calculate the normal for this triangle and assign it to up. The normal should be calculated as follows:

first_point-second_point X second_point-third_point

Since we have an up (we use the value just calculated), we can call towards first_point "left" and towards second_point "right". Each of the new triangle edges just added are known as such: there is a left and right "side" to the triangle from our perspective.

For the next pass of the loop, we go LEFT ONLY so assign...

second_point = global value of third_point

The first point does not change (here) because we are going left and therefore the "first point" in the triangle (the 'oldest' point) remains the same.

This ends the first pass of the loop.

NOTE: for now, only go to the left each time.

We can do this in the "right" direction, but not now please.

Place a green sphere of radius 1/20 at each point. Connect the points with lines in the form of cylinders of radius 1/30.

The line between our first two given points should be white, all "left" cylinders should be blue and all right cylinders red.

Do not animate this. Just write the code to create the shape, add a camera a coordinates 10,10,10 looking at the origin.