It's been quite awhile since Scripting Helpers hosted its last Snack Break challenge but I'm excited to breath some life into this three-year tradition! For those of you who are unfamiliar, the goal of a Snack Break is to provide a quick and thought provoking challenge that programmers of all skill levels can get something out of.
Unfortunately, it seems either that this challenge was too hard or there was not a lot of interest in it and as a result I have received no completed solutions. I have to say I'm a bit disappointed as I thought challenge levels one and two were quite reasonable, but I guess I'll just have to tone it down in the future.
Regardless, I promised I would provide my solutions to all there challenges so here you go.
In this challenge we're going to be celebrating the recently released new CSG API by trying to solve some problems that it makes trivial, but here’s the catch, you’re not allowed to use the CSG API!
This challenge consists of three levels of varying difficulty that all build on top of each other.
The rules are as follows:
- You can not use the CSG API in any capacity.
- You may not submit duplicates of somebody else's answers.
- You should not use any pre-written libraries for this. i.e. no CSG modules written in Lua, etc.
Challenge: Level One
In this challenge the goal is to slice an axis-aligned part in half given an axis-aligned plane that represents where the slice will be.
The blue part represents the plane that slices the grey part in half
A few things you can note:
- Axis-aligned means no rotation.
- The plane should be able to cut on any aligned axis (x, y, or z).
- The planes are to represented as infinite, but your solution should also account for when the plane does not intersect the shape and no cuts should be made.
Challenge: Level Two
This challenge is quite like the previous with the exception that it should now be able to use multiple planes to make multiple "cuts" to the same part. Again, the part and planes should be axis-aligned.
Four parts are created!
Challenge: Level Three
This challenge is by far the most difficult but reaps the largest reward! The first three people who manage to complete this will receive the Snack Break badge on their SH account!
The goal of this challenge is once again to split a part using a single plane except now both parts can be rotated!
This one is quite a toughie so I'm excited to see solutions (if any!).
Discussion and where to send your answers
Discussion of the problem is welcome in the Scripting Helpers Discord (so make sure to join!). You can post your answers either as a free model or as an uncopylocked place. The links can either be posted in the comments or DM'd to me (EgoMoose) on discord.
I'm going to give you guys approximately a week to solve this one so by 10:00pm UTC September 22nd I want your answers in! Soon after I’ll announce those who completed each challenge along with my own solutions.