Discuss Scratch

griefercube
Scratcher
500+ posts

Triangle-ating objects (3D)

So I’m trying to achieve cutting some points into triangles to fill the shape, but how do I ensure that the triangles don’t go awry?

So, like I have a square.
There are 4 vertices on a square.
Each vertice has 2 points, so the square has 8 points (points overlap)
The vertices are drawn according to order in a list which is updated frequently so the vertices are drawn in random order.
I want to use 2 triangles to cover the square.
Each triangle has 3 points.
The triangles need to follow the random vertice list too.
So which two points should I add to make the triangles’ points complete?
The project: https://turbowarp.org/575520435/editor/

Last edited by griefercube (Oct. 2, 2021 15:04:38)



sometimes, you just have to change a way of thinking to solve a problem. -griefercube
|other projectshow I made the banneranimated thumbnails?i’m on wiki!Cubey Mines|

Last edited by griefercube (32th Undecimber, XXXX)


https://turbowarp.org/563693837/editor (something i did a while back don’t worry it’s for the banner)

list of working bbcodes:

[color=]
[scratchblocks]
[url=]
[img]
[center]
[code]
[code=]
[list]
[quote]
[b]
[i]
[u]
[s]
[big]
[small]
[p]
[wiki]
[google]
Spentine
Scratcher
1000+ posts

Triangle-ating objects (3D)

Choose 4 points, A B C and D.
Triangle one covers A B and C.
Triangle two covers B C and D.

A–B
| |
C–D

pls dont comment “a” on my profile

also my connect 4 AI
griefercube
Scratcher
500+ posts

Triangle-ating objects (3D)

I know, but how to split it


sometimes, you just have to change a way of thinking to solve a problem. -griefercube
|other projectshow I made the banneranimated thumbnails?i’m on wiki!Cubey Mines|

Last edited by griefercube (32th Undecimber, XXXX)


https://turbowarp.org/563693837/editor (something i did a while back don’t worry it’s for the banner)

list of working bbcodes:

[color=]
[scratchblocks]
[url=]
[img]
[center]
[code]
[code=]
[list]
[quote]
[b]
[i]
[u]
[s]
[big]
[small]
[p]
[wiki]
[google]
griefercube
Scratcher
500+ posts

Triangle-ating objects (3D)

And ABCD isn’t consistent


sometimes, you just have to change a way of thinking to solve a problem. -griefercube
|other projectshow I made the banneranimated thumbnails?i’m on wiki!Cubey Mines|

Last edited by griefercube (32th Undecimber, XXXX)


https://turbowarp.org/563693837/editor (something i did a while back don’t worry it’s for the banner)

list of working bbcodes:

[color=]
[scratchblocks]
[url=]
[img]
[center]
[code]
[code=]
[list]
[quote]
[b]
[i]
[u]
[s]
[big]
[small]
[p]
[wiki]
[google]
DavidJag
Scratcher
73 posts

Triangle-ating objects (3D)

griefercube wrote:

And ABCD isn’t consistent

You should define the points of your un-transformed square in clockwise order (a list of 4 points, A B C D):

A–B
| |
D–C

Once you have perform the 3d transformation and projected the points back to the screen you should have a transformed list of points. The order in the list will still be A B C D.

Now draw two triangles, A B C and A C D

Be a banana

Can you get to the top of the scoreboard?: Rocks in Space!

Some 3D: Loopy d' loop
griefercube
Scratcher
500+ posts

Triangle-ating objects (3D)

That's the easiest way?


sometimes, you just have to change a way of thinking to solve a problem. -griefercube
|other projectshow I made the banneranimated thumbnails?i’m on wiki!Cubey Mines|

Last edited by griefercube (32th Undecimber, XXXX)


https://turbowarp.org/563693837/editor (something i did a while back don’t worry it’s for the banner)

list of working bbcodes:

[color=]
[scratchblocks]
[url=]
[img]
[center]
[code]
[code=]
[list]
[quote]
[b]
[i]
[u]
[s]
[big]
[small]
[p]
[wiki]
[google]
DavidJag
Scratcher
73 posts

Triangle-ating objects (3D)

What is the difficulty?


Be a banana

Can you get to the top of the scoreboard?: Rocks in Space!

Some 3D: Loopy d' loop
griefercube
Scratcher
500+ posts

Triangle-ating objects (3D)

There are 12 points that make the cube, and I have to do it to all of them


sometimes, you just have to change a way of thinking to solve a problem. -griefercube
|other projectshow I made the banneranimated thumbnails?i’m on wiki!Cubey Mines|

Last edited by griefercube (32th Undecimber, XXXX)


https://turbowarp.org/563693837/editor (something i did a while back don’t worry it’s for the banner)

list of working bbcodes:

[color=]
[scratchblocks]
[url=]
[img]
[center]
[code]
[code=]
[list]
[quote]
[b]
[i]
[u]
[s]
[big]
[small]
[p]
[wiki]
[google]
DavidJag
Scratcher
73 posts

Triangle-ating objects (3D)

griefercube wrote:

There are 12 points that make the cube, and I have to do it to all of them

A cube only has 8 points. I assume you mean 12 triangles to make a cube?

You appear to have a list of points (called ‘lines’) with every point defined once for every face (6 faces, 4 points per face. 3 coordinates per point, 6 * 4 * 3 = 72)

Each point is shared by 3 faces so you have 3 times as many points defined as you need.

So, firstly, just define the 8 points of the cube (I'd probably use 3 separate lists for the x, y and z coordinates)

Then define a list of the 6 faces as indexes into the points list e.g.:
1, 2, 3, 4, 2, 5, 6, 3, 1, 8, 5, 2 etc….
–face 1– – face 2– – face 3-

Now to find the triangles, go through the list of faces and for each face pick the 1st, 2nd and 3rd point for triangle number 1 and the 1st, 3rd and 4th point for traingle number 2 e.g. for the 2nd face in the list I defined above.
Triangle 1 = 2, 5, 6
Triangle 2 = 2, 6, 3

Then use those indexes to lookup the actual points in your x, y and z lists.

Last edited by DavidJag (Oct. 3, 2021 16:52:45)


Be a banana

Can you get to the top of the scoreboard?: Rocks in Space!

Some 3D: Loopy d' loop
griefercube
Scratcher
500+ posts

Triangle-ating objects (3D)

Yeah, I meant that…

Thanks I guess?

(P.s. i used vertices for each line (not point) so it might be a bit harder)


sometimes, you just have to change a way of thinking to solve a problem. -griefercube
|other projectshow I made the banneranimated thumbnails?i’m on wiki!Cubey Mines|

Last edited by griefercube (32th Undecimber, XXXX)


https://turbowarp.org/563693837/editor (something i did a while back don’t worry it’s for the banner)

list of working bbcodes:

[color=]
[scratchblocks]
[url=]
[img]
[center]
[code]
[code=]
[list]
[quote]
[b]
[i]
[u]
[s]
[big]
[small]
[p]
[wiki]
[google]

Powered by DjangoBB