From 892e6fb276db42818ce7e5fd315dee071dbb94ee Mon Sep 17 00:00:00 2001 From: Yoann Date: Tue, 10 Jan 2012 11:31:42 +0100 Subject: [PATCH 1/2] =?UTF-8?q?Ajout=20d'une=20fonction=20insetOpp()=20qui?= =?UTF-8?q?=20d=C3=A9place=20le=20c=C3=B4t=C3=A9=20oppos=C3=A9=20pour=20le?= =?UTF-8?q?=20placer=20=C3=A0=20la=20distance=20indiqu=C3=A9e,=20et=20le?= =?UTF-8?q?=20rendre=20parall=C3=A8le=20=C3=A0=20celui=20de=20r=C3=A9f?= =?UTF-8?q?=C3=A9rence.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- geometry/quad.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/geometry/quad.cpp b/geometry/quad.cpp index 0bb3295..ac6738c 100644 --- a/geometry/quad.cpp +++ b/geometry/quad.cpp @@ -27,6 +27,15 @@ Quad Quad::insetNESW(float offset) const { return insetNESW(offset, offset, offset, offset); } +Quad Quad::insetOpp(Cardinal side, float offset) const { + Quad q = (*this) << int(side); + Quad qb = (*this) << int(side); + + qb = qb.inset(N,offset); + return Quad(q[NE],qb[NE],qb[NW],q[NW]); + +} + Quad Quad::makeParallelogram() const { float l1, l2; Quad q(c[NE],c[SE],c[SW],c[NW]); From 8e916890b0d9a5ba510ac3ec58f2343884f2080e Mon Sep 17 00:00:00 2001 From: Yoann Date: Tue, 10 Jan 2012 11:32:52 +0100 Subject: [PATCH 2/2] =?UTF-8?q?R=C3=A9-impl=C3=A9mentation=20de=20la=20d?= =?UTF-8?q?=C3=A9composition=20du=20block=20en=20murs=20lors=20des=20split?= =?UTF-8?q?s.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- geometry/quad.hh | 1 + rules/batiment/batimentquadblock.cpp | 19 ++++--------------- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/geometry/quad.hh b/geometry/quad.hh index 043c6d6..3a1274c 100644 --- a/geometry/quad.hh +++ b/geometry/quad.hh @@ -27,6 +27,7 @@ class Quad { Quad inset(Cardinal side, float offset) const; Quad insetNESW(float offsetN, float offsetE, float offsetS, float offsetW) const; Quad insetNESW(float offset) const; + Quad insetOpp(Cardinal side, float offset) const; float length(Cardinal side) const; float minLengthNS() const; float minLengthEW() const; diff --git a/rules/batiment/batimentquadblock.cpp b/rules/batiment/batimentquadblock.cpp index 50dc3a9..2339965 100644 --- a/rules/batiment/batimentquadblock.cpp +++ b/rules/batiment/batimentquadblock.cpp @@ -10,21 +10,10 @@ void BatimentQuadBlock::getBoundingBoxPoints() { } bool BatimentQuadBlock::split() { - Quad me = c; - Quad ms = c; - Quad mw = c; - Quad mn = c; - - me[NW] = me[NE] + ((me[NW] - me[NE]) / me.length(N))*28; - me[SW] = me[SE] + ((me[SW] - me[SE]) / me.length(S))*28; - mw[NE] = mw[NW] + ((mw[NE] - mw[NW]) / mw.length(N))*28; - mw[SE] = mw[SW] + ((mw[SE] - mw[SW]) / mw.length(S))*28; - mn.inset(W,-28); mn.inset(E,-28); - mn[SW] = mn[NW] + ((mn[SW] - mn[NW]) / mn.length(W))*28; - mn[SE] = mn[NE] + ((mn[SE] - mn[NE]) / mn.length(E))*28; - ms.inset(W,-28); ms.inset(E,-28); - ms[NW] = ms[SW] + ((ms[NW] - ms[SW]) / ms.length(W))*28; - ms[NE] = ms[SE] + ((ms[NE] - ms[SE]) / ms.length(E))*28; + Quad me = c.insetOpp(E,28); + Quad ms = c.inset(E,-28).inset(W,-28).insetOpp(S,28); + Quad mw = c.insetOpp(W,28); + Quad mn = c.inset(E,-28).inset(W,-28).insetOpp(N,28); addChild(new BatimentQuadMur(me,height)); addChild(new BatimentQuadMur(mw,height));