Guest Jim69 Posted September 20, 2003 Report Share Posted September 20, 2003 Hey I did a quick bit of code to work out the angles for the circular UFO walls I was designing so that they are 1m chunks. Unfortunatly I haven't got a compilier and wouldn't understand any errors if I had one, can someone give this a once over if they get the time to see if there are any problems with it? #include <Math.h> #include <stdio.h> int Main () { int btmFace, leftFace, rightFace, topAngle, diameter, block (); double topAngleCos (); float totalAngle, totalBlocks (); // Get measurements of polygon for calculations cout >> "Enter the desired diameter of the shape:/n"; cin >> diameter "/n"; cout >> "Enter the length of one wall block ( should be 1m ):/n"; cin >> block "/n"; // Setup variables; btmFace = block; leftFace = diameter / 2; rightFace = leftFace; // Main calculations; topAngleCos = ( (btmFace * btmFace) + (leftFace * leftFace ) - ( rightFace * rightFace ) ) / ( 2 * rightFace * leftFace ); topAngle = cos (topAngleCos); totalBlocks = 360 / topAngle; cout >> "The total angle that the block needs to be set at is " topangle "./n"; cout >> "The total amount of blocks needed to perform this is " totalBlocks"./n"; cout >> "The angle of the blocks sound be divided amongst both sides, and should be rounded to whatever decimals your 3D modelling program uses ( 3D Studio MAX allows 3 decimal places )./n"; cout >> "If the number of blocks is odd then the diameter should be adjusted so that it does use a whole number of blocks or it may not tile correctly./n"; int anykey (); cout >> "Press return to exit/n"; cin >> anykey; return 0; } Link to comment Share on other sites More sharing options...
Cpl. Facehugger Posted September 20, 2003 Report Share Posted September 20, 2003 Umm, Why is this in the ontopic forum? Link to comment Share on other sites More sharing options...
Extralucas Posted September 21, 2003 Report Share Posted September 21, 2003 Probably refers to both, TFTD and UFO games. However, I have no idea what does this code mean. Link to comment Share on other sites More sharing options...
Guest Jim69 Posted September 21, 2003 Report Share Posted September 21, 2003 I couldn't think of a better place to put it, not really image department, not really something to put in programming department, not really for the lab so this was the best place to put it. It is for UFO plan designs but code ain't exactly the thing to put into the art department I think. Link to comment Share on other sites More sharing options...
[[Micah]] Posted September 21, 2003 Report Share Posted September 21, 2003 On Topic is for matters related to the commercially developed X-COM game series.... Link to comment Share on other sites More sharing options...
[stewart] Posted September 21, 2003 Report Share Posted September 21, 2003 Well let's try this forum! Link to comment Share on other sites More sharing options...
[stewart] Posted September 21, 2003 Report Share Posted September 21, 2003 Your algorythm does not take into account, as far as I can tell, if the wall can be broken down into exact metre chunks regardless as to whether there is an odd or even number of them. Unless of course, you will throw in metre long wall sections with the last one being less than a metre not being a problem. Link to comment Share on other sites More sharing options...
Guest Jim69 Posted September 21, 2003 Report Share Posted September 21, 2003 (edited) This forum seems fine. You are right, the reason being I don't quite know how to do this. I was thinking the only way to do it is wait for the result and tell the user that if the blocks are not a whole number then he may have to tweak the diameter settings until it shows an integer. That is why I made sure that the blocks number was a Float, so that at least the user is awear of the problem instead of waiting to try fitting the pieces together. Another thing I thought of is this: What if it was made sure that the number was always on the larger size so that the doorways are a little bigger? That could solve the problem because it will never be a continuous circle. Edited September 21, 2003 by Jim69 Link to comment Share on other sites More sharing options...
[stewart] Posted September 21, 2003 Report Share Posted September 21, 2003 Well how variable is the diameter of these UFOs gonna be. You could probably just generate a look-up table. Ex UFO with 27 1 meter wall-sections corresponds to 14.7m diameter or something like that. Everything is generated up-front then the game just goes and looks it up based on diameter. So for a diameter of 14 metres it uses the result of 14.7. Link to comment Share on other sites More sharing options...
Guest Jim69 Posted September 21, 2003 Report Share Posted September 21, 2003 I was thinking as this of more of an artists tool for creating UFO plans if we do eventually decide on using my system. So, if someone draws up the plans in actual circles and we work out the diameter then it would be easy enough to look at a lookup table to find out the diameter we should use for them to tile correctly. However doing this without a computer is hard work so this small piece of code could make creating that table a formality. Also, should we use the system I am thinking of, we could include both the look up table and this code for the end user to create their own UFO maps. Link to comment Share on other sites More sharing options...
[stewart] Posted September 22, 2003 Report Share Posted September 22, 2003 Actually you shouldn't need even a program for it. It's just a math formula, lets see . . . . You know 1) the angle, its 360°/(desired number of sides)/22) the opposite side of the triangle is 1/2 metre therefore the lengh of the hypotenuse will be the radius of the ship. So . . . . Radius = 1/2 metre / ASIN_deg(180/sides) Playing with excel reveals a few choice tidbits . . . 16 sides corresponds to an approximate diameter of 10.2 metres.24 ...............................................................................1.3 ...........32 -> 20.340 -> 25.548 -> 30.6 Link to comment Share on other sites More sharing options...
Guest Jim69 Posted September 22, 2003 Report Share Posted September 22, 2003 Unfortunatly I haven't got Excel :whatwhat: I don't know why I didn't think of using it, I've only been doing forumlae in it for 2 years I'll set one up and post it for anyones reference who wants it I may have to *get* myself a copy. Link to comment Share on other sites More sharing options...
Guest Jim69 Posted September 22, 2003 Report Share Posted September 22, 2003 Actually you shouldn't need even a program for it. It's just a math formula, lets see . . . . You know 1) the angle, its 360°/(desired number of sides)/22) the opposite side of the triangle is 1/2 metre therefore the lengh of the hypotenuse will be the radius of the ship. So . . . . Radius = 1/2 metre / ASIN_deg(180/sides) Playing with excel reveals a few choice tidbits . . . 16 sides corresponds to an approximate diameter of 10.2 metres.24 ...............................................................................1.3 ...........32 -> 20.340 -> 25.548 -> 30.6Also, with the forumale you have there is a problem: You actually have to work with either: The desired diameterThe outside length of one block ( 1m ) And you have to work out what it would be with that. The best way to work it out I think is to seperate the shape into isosolies triangles so we know that two of the sides are the same ( which both equal the radius or in this case half the diameter ) so we have a isoselies triangle with all three sides but no angles. What we need to work out is the angle where both equal lengths dissect. This is where the problem occours because I couldn't find anything on the net about it so I looked thru some of my bro's degree level maths books ( considering I only did GCSE level I wouldn't be surprised if I got it wrong ). The current forulae I just tried don't work so I could have a problem, I may have to look it up again :whatwhat: Link to comment Share on other sites More sharing options...
[stewart] Posted September 23, 2003 Report Share Posted September 23, 2003 If you want the outside of the UFO to be in exact metre size wall sections the use what I discribed. If you want specific diameters for the UFOs then you have two choicesa) You allow wall sections of sizes not equal to one metre You allow ONE wall section of width less than one metre. Link to comment Share on other sites More sharing options...
Guest Jim69 Posted September 23, 2003 Report Share Posted September 23, 2003 I've been doing some thinking about this. There is a way around this, as long as the gap doesn't become too big. The actual walls could be replacable but the brackets either side could be freestanding and destroyed if there is no wall either side. Link to comment Share on other sites More sharing options...
Guest Jim69 Posted September 23, 2003 Report Share Posted September 23, 2003 D'oh! No edit. Forgot a part. Then we can stretch the brackets slightly as they are independant of the wall and still maintain the 1m blocks. Link to comment Share on other sites More sharing options...
[stewart] Posted September 23, 2003 Report Share Posted September 23, 2003 Well if you want to call brackets as not part of the wall, you go ahead; that'll work. Link to comment Share on other sites More sharing options...
Breunor Posted September 23, 2003 Report Share Posted September 23, 2003 (edited) Here's a suggestion. If you start with a sample room with a circumference of 12m, you get 3-4 meters inside, maybe enough for a power supply. To add at least a 1 meter hallway all the way around, add 7 to the circumference each time. So you have 19m, 26m, 33m, etc. Each ring is a little more than 2 meters larger in diameter. If you want a 5m inner room, then you find the closest interger with diameter times pie, 5x3.14=15.7 rounds to 16. So your first wall needs 16 sections, then the next ring needs 23 to allow for minimum clearance and so on. The question I see is whether the perpendicular walls would meet up in a neat manner, probably not. So you could shoot a wall out to find a perpendicular wall in the middle of that hole, and be forced to shoot it out as well to pass through. Of course, if we don't allow weapons to destroy ufo walls... problem solved! Edited September 23, 2003 by Breunor Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now