/* not included yet */ /* * trail - traveller support library * Copyright (c) 2004 Danny Milosavljevic * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License Version 2.1, * or (at your option) any later version. * * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser * General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include /* Calculations by Nathalie Kopaczewski :) dannym: I have a rectangle "M" which is for the total available space dannym: then I have a smaller rectangle "I" which is centered in "M" dannym: (in it there will be a cute icon but thats beside the point ;)) dannym: and now there is space between the rectangle M and the rectangle I in that space I want to place additional cute icons, err emblems (rectangle E0, E1, E2....), so that it will be aligned in a circle. dannym: they will orbit the main icon like planets orbit the sun :) dannym: just the sun is rectangly :) dannym: corner conditions are thus I < M C between I and M, C not intersecting center(E0) somewhere on C center(E1) somewhere on C ... E.x not intersecting with M and not intersecting with I E.x as big as possible (but not bigger :)) dannym: searched for is: - ideal radius for C so that E.x as big as possible - E.x Nat: length(I) < lenght(M)/sqrt(2) 14:49 Nat: if =, then length(E.x)= 0. And if >, then it's impossible Nat: if you set the size of the main icon, I can give you formulas for the radius of C and size of E;x Nat: I name LE, LI, LM the length of the side of the squares E;x, I and M Nat: RC the radius of C Nat: and S2 is square root of 2 RC=(LM+LI)/(2+S2) LE=(LM-S2*LI)/(1+S2) Nat: and here, you see in the formula giving LE that you must have what I told you before: LM-S2*LI must be >=O Nat: if =0, LE=0 though :P RC=(LM-LE)/2 LI=(LM-(1+S2)*LE)/S2 Nat: actually, the LE I am calculating with these formulas is the max dannym: I see :) Nat: max so that it stays inside M and outisde I. Nat: but you can use the same RC and a smaller LE, it will just not touch I and M when rotating */ /* gdouble s2 = sqrt(2) */