<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[array um die x-achse spiegeln]]></title><description><![CDATA[<p>hallo,<br />
ich habe ein array mit fixer größe was ein koordinatensystem repräsentiert.<br />
(die länge der x achse ist bekannt) also repräsentieren alle x elemente des arrays eine zeile im koordinatensystem.</p>
<p>die erter position (array[0]) ist repräsentiert im koordinaten system die linke untere ecke...</p>
<p>ich möchte mein array so spiegeln dass wenn ich einen punkt z.b. (0,0) im array ableg dies nicht die linke untere sondern die linke obere ecke repräsentiert. das wäre dann bei einem array der länge 25 die position array[20].</p>
<p>hat jemand eine idee wie ich das bewerkstelligen kann?<br />
müsste nur von der position im &quot;normalen&quot; array soundso viel positionen dazuaddieren um auf die position im gespiegelten fall zu kommen...</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/237407/array-um-die-x-achse-spiegeln</link><generator>RSS for Node</generator><lastBuildDate>Wed, 23 Sep 2026 10:14:34 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/237407.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 28 Mar 2009 12:28:54 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to array um die x-achse spiegeln on Sat, 28 Mar 2009 12:28:54 GMT]]></title><description><![CDATA[<p>hallo,<br />
ich habe ein array mit fixer größe was ein koordinatensystem repräsentiert.<br />
(die länge der x achse ist bekannt) also repräsentieren alle x elemente des arrays eine zeile im koordinatensystem.</p>
<p>die erter position (array[0]) ist repräsentiert im koordinaten system die linke untere ecke...</p>
<p>ich möchte mein array so spiegeln dass wenn ich einen punkt z.b. (0,0) im array ableg dies nicht die linke untere sondern die linke obere ecke repräsentiert. das wäre dann bei einem array der länge 25 die position array[20].</p>
<p>hat jemand eine idee wie ich das bewerkstelligen kann?<br />
müsste nur von der position im &quot;normalen&quot; array soundso viel positionen dazuaddieren um auf die position im gespiegelten fall zu kommen...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1687364</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1687364</guid><dc:creator><![CDATA[c87]]></dc:creator><pubDate>Sat, 28 Mar 2009 12:28:54 GMT</pubDate></item><item><title><![CDATA[Reply to array um die x-achse spiegeln on Sat, 28 Mar 2009 12:39:47 GMT]]></title><description><![CDATA[<p>c87 schrieb:</p>
<blockquote>
<p>die erter position (array[0]) ist repräsentiert im koordinaten system die linke untere ecke...</p>
<p>ich möchte mein array so spiegeln dass wenn ich einen punkt z.b. (0,0) im array ableg dies nicht die linke untere sondern die linke obere ecke repräsentiert. das wäre dann bei einem array der länge 25 die position array[20].</p>
</blockquote>
<p>Bei einem Array der Länge 25 der Index 20? Wie kommst du denn darauf? Ist das nicht mit einfacher Subtraktion vom maximalen Index zu lösen?</p>
<p>Ansonsten beschreib dein Problem genauer, und achte ein wenig auf die Formulierung...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1687371</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1687371</guid><dc:creator><![CDATA[Nexus]]></dc:creator><pubDate>Sat, 28 Mar 2009 12:39:47 GMT</pubDate></item><item><title><![CDATA[Reply to array um die x-achse spiegeln on Sat, 28 Mar 2009 12:45:04 GMT]]></title><description><![CDATA[<p>statt<br />
arr[y*sizeX+x]<br />
nimm<br />
arr[(sizeY-y)*sizeX+x]<br />
und gespiegelt ist es.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1687374</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1687374</guid><dc:creator><![CDATA[volkard]]></dc:creator><pubDate>Sat, 28 Mar 2009 12:45:04 GMT</pubDate></item><item><title><![CDATA[Reply to array um die x-achse spiegeln on Sat, 28 Mar 2009 12:51:27 GMT]]></title><description><![CDATA[<p>ich habe ein array. Nehmen wir als größe mal 25.<br />
der erste wert im array ist im koordinaten system (0,0) an der linken unteren ecke. Das ist fix.</p>
<p>Ich möchte aber den koordinatenursprung an der linken oberen ecke haben. das heißt ich muss mir ausrechnen welche position im array diese obere linke ecke darstellt. das wär bei bei dem array die pos 20.</p>
<pre><code>20x x x x   array[20-24]
x x x x     array[15-19]
x x x x x   array[10-14]
x x x x x   array[5-9]
0 x x x x   array[0-4]
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1687378</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1687378</guid><dc:creator><![CDATA[c87]]></dc:creator><pubDate>Sat, 28 Mar 2009 12:51:27 GMT</pubDate></item><item><title><![CDATA[Reply to array um die x-achse spiegeln on Sat, 28 Mar 2009 13:12:43 GMT]]></title><description><![CDATA[<p>volkard schrieb:</p>
<blockquote>
<p>statt<br />
arr[y*sizeX+x]<br />
nimm<br />
arr[(sizeY-y)*sizeX+x]<br />
und gespiegelt ist es.</p>
</blockquote>
<p>volkard schrieb:</p>
<blockquote>
<p>statt<br />
arr[y*sizeX+x]<br />
nimm<br />
arr[(sizeY-y)*sizeX+x]<br />
und gespiegelt ist es.</p>
</blockquote>
<p>das funktioniert leider auch nicht:<br />
bei array der länge 25: einfügen: (2,1)</p>
<p>position im array: 7:<br />
position gespiegelt: sollte 17 sein</p>
<pre><code>x x 22x x 
x x * x x
x x x x x
x x 7 x x
x x x x x
</code></pre>
<p>(5-1)*5 +2 = 22 falsch</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1687395</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1687395</guid><dc:creator><![CDATA[c87]]></dc:creator><pubDate>Sat, 28 Mar 2009 13:12:43 GMT</pubDate></item><item><title><![CDATA[Reply to array um die x-achse spiegeln on Sat, 28 Mar 2009 13:20:07 GMT]]></title><description><![CDATA[<p>arr[((sizeY-1)-y)*sizeX+x]?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1687399</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1687399</guid><dc:creator><![CDATA[volkard]]></dc:creator><pubDate>Sat, 28 Mar 2009 13:20:07 GMT</pubDate></item><item><title><![CDATA[Reply to array um die x-achse spiegeln on Sat, 28 Mar 2009 13:29:42 GMT]]></title><description><![CDATA[<p>hab bissl rumprobiert.<br />
so hauts hin:<br />
<strong>(sizeY-(y+1)) * sizeX + x</strong></p>
<p>dankeschön</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1687406</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1687406</guid><dc:creator><![CDATA[c87]]></dc:creator><pubDate>Sat, 28 Mar 2009 13:29:42 GMT</pubDate></item><item><title><![CDATA[Reply to array um die x-achse spiegeln on Sat, 28 Mar 2009 14:40:20 GMT]]></title><description><![CDATA[<p>c87 schrieb:</p>
<blockquote>
<p>so hauts hin:<br />
<strong>(sizeY-(y+1)) * sizeX + x</strong></p>
</blockquote>
<p>das hatte volkard doch bereits geschrieben...<br />
btw:<br />
(sizeY-y-1) * sizeX + x</p>
<p>man muss nich überall klammern setzen ;o)</p>
<p>bb</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1687459</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1687459</guid><dc:creator><![CDATA[unskilled]]></dc:creator><pubDate>Sat, 28 Mar 2009 14:40:20 GMT</pubDate></item><item><title><![CDATA[Reply to array um die x-achse spiegeln on Sat, 28 Mar 2009 14:47:25 GMT]]></title><description><![CDATA[<p>unskilled schrieb:</p>
<blockquote>
<p>btw:<br />
(sizeY-y-1) * sizeX + x<br />
man muss nich überall klammern setzen ;o)</p>
</blockquote>
<p>meine klammer bei [((sizeY-1)-y war ein wink mit dem zaunpfahl an den compiler, daß er (sizeY-1) gefälligst zu optimieren hat. passiert irgendwie von allein beim tippen. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1687469</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1687469</guid><dc:creator><![CDATA[volkard]]></dc:creator><pubDate>Sat, 28 Mar 2009 14:47:25 GMT</pubDate></item><item><title><![CDATA[Reply to array um die x-achse spiegeln on Sat, 28 Mar 2009 14:52:50 GMT]]></title><description><![CDATA[<p>volkard schrieb:</p>
<blockquote>
<p>unskilled schrieb:</p>
<blockquote>
<p>btw:<br />
(sizeY-y-1) * sizeX + x<br />
man muss nich überall klammern setzen ;o)</p>
</blockquote>
<p>meine klammer bei [((sizeY-1)-y war ein wink mit dem zaunpfahl an den compiler, daß er (sizeY-1) gefälligst zu optimieren hat. passiert irgendwie von allein beim tippen. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
</blockquote>
<p>Wie ich immer wieder sage: ich vertraue meinem Compiler da eh blind - und vll will er ja lieber y-1 optimieren und nich sizeX-1 <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61b.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_tongue"
      title=":P"
      alt="😛"
    /><br />
Ich finds auf jeden Fall hässlich, ne Gleichnung mit so vielen Klammern zu haben - (in dem Fall) zwar nicht gleich total unleserlich, aber au nich besser ^^ und bei dir war mir das scho klar, dass du weist, welche klammern gebraucht werden und welche nich <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
<p>bb</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1687472</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1687472</guid><dc:creator><![CDATA[unskilled]]></dc:creator><pubDate>Sat, 28 Mar 2009 14:52:50 GMT</pubDate></item><item><title><![CDATA[Reply to array um die x-achse spiegeln on Sat, 28 Mar 2009 14:54:51 GMT]]></title><description><![CDATA[<p>unskilled schrieb:</p>
<blockquote>
<p>Wie ich immer wieder sage: ich vertraue meinem Compiler da eh blind - und vll will er ja lieber y-1 optimieren und nich sizeX-1 <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61b.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_tongue"
      title=":P"
      alt="😛"
    /></p>
</blockquote>
<p>bei integers kannste dem gerne vertrauen.<br />
bei doubles würde ich davon abstand nehmen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1687474</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1687474</guid><dc:creator><![CDATA[volkard]]></dc:creator><pubDate>Sat, 28 Mar 2009 14:54:51 GMT</pubDate></item><item><title><![CDATA[Reply to array um die x-achse spiegeln on Sat, 28 Mar 2009 15:11:44 GMT]]></title><description><![CDATA[<p>volkard schrieb:</p>
<blockquote>
<p>unskilled schrieb:</p>
<blockquote>
<p>Wie ich immer wieder sage: ich vertraue meinem Compiler da eh blind - und vll will er ja lieber y-1 optimieren und nich sizeX-1 <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61b.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_tongue"
      title=":P"
      alt="😛"
    /></p>
</blockquote>
<p>bei integers kannste dem gerne vertrauen.<br />
bei doubles würde ich davon abstand nehmen.</p>
</blockquote>
<p>ich wollts ja gerade mal ausprobieren - aber meine asm-kenntnisse sind zu schlecht, um das richtig deuten zu können ^^</p>
<pre><code class="language-cpp">int main()
{
	double sizeY;
	std::cin &gt;&gt; sizeY;
	double y;
	std::cin &gt;&gt; y;
	double sizeX;
	std::cin &gt;&gt; sizeX;
	double x;
	std::cin &gt;&gt; x;

	double R = (sizeY-y-1) * sizeX + x; //1
	double R = (sizeY-(y+1)) * sizeX + x; //2
	std::cout &lt;&lt; R;
}
</code></pre>
<p>1:</p>
<pre><code class="language-asm">00C7104D  fld         qword ptr [esp+20h] 
00C71051  fsub        qword ptr [esp+28h] 
00C71055  mov         ecx,dword ptr [__imp_std::cout (0C72044h)] 
00C7105B  sub         esp,8 
00C7105E  fsub        qword ptr [__real@3ff0000000000000 (0C72118h)] 
00C71064  fmul        qword ptr [esp+38h] 
00C71068  fadd        qword ptr [esp+40h] 
00C7106C  fstp        qword ptr [esp]
</code></pre>
<p>2:</p>
<pre><code class="language-asm">00E1104D  fld         qword ptr [esp+20h] 
00E11051  fadd        qword ptr [__real@3ff0000000000000 (0E12118h)] 
00E11057  mov         ecx,dword ptr [__imp_std::cout (0E12044h)] 
00E1105D  sub         esp,8 
00E11060  fsubr       qword ptr [esp+30h] 
00E11064  fmul        qword ptr [esp+38h] 
00E11068  fadd        qword ptr [esp+40h] 
00E1106C  fstp        qword ptr [esp]
</code></pre>
<p>sieht aber so aus, als ob es sich nix nehmen würde^^</p>
<p>bb</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1687484</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1687484</guid><dc:creator><![CDATA[unskilled]]></dc:creator><pubDate>Sat, 28 Mar 2009 15:11:44 GMT</pubDate></item><item><title><![CDATA[Reply to array um die x-achse spiegeln on Sat, 28 Mar 2009 15:14:28 GMT]]></title><description><![CDATA[<p>und mit</p>
<pre><code class="language-cpp">double const sizeY=5;
double const sizeX=5;
</code></pre>
<p>?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1687485</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1687485</guid><dc:creator><![CDATA[volkard]]></dc:creator><pubDate>Sat, 28 Mar 2009 15:14:28 GMT</pubDate></item><item><title><![CDATA[Reply to array um die x-achse spiegeln on Sat, 28 Mar 2009 15:23:09 GMT]]></title><description><![CDATA[<p>volkard schrieb:</p>
<blockquote>
<p>und mit</p>
<pre><code class="language-cpp">double const sizeY=5;
double const sizeX=5;
</code></pre>
<p>?</p>
</blockquote>
<p>Deine Variante:</p>
<pre><code class="language-asm">008F102B  fld         qword ptr [esp+30h] 
008F102F  fadd        qword ptr [__real@3ff0000000000000 (8F2120h)] 
008F1035  mov         ecx,dword ptr [__imp_std::cout (8F2044h)] 
008F103B  fld         qword ptr [__real@4014000000000000 (8F2118h)] 
008F1041  sub         esp,8 
008F1044  fld         st(0) 
008F1046  fsubrp      st(2),st 
008F1048  fmulp       st(1),st 
008F104A  fadd        qword ptr [esp+40h] 
008F104E  fstp        qword ptr [esp] 
008F1051  call        dword ptr [__imp_std::basic_ostream&lt;char,std::char_traits&lt;char&gt; &gt;::operator&lt;&lt; (8F2040h)]
</code></pre>
<p>Die &quot;normale&quot; Variante (also die ohne klammern):</p>
<pre><code class="language-asm">0111102B  fld         qword ptr [__real@4014000000000000 (1112120h)] 
01111031  fld         qword ptr [esp+30h] 
01111035  mov         ecx,dword ptr [__imp_std::cout (1112044h)] 
0111103B  fsubr       st,st(1) 
0111103D  sub         esp,8 
01111040  fsub        qword ptr [__real@3ff0000000000000 (1112118h)] 
01111046  fmulp       st(1),st 
01111048  fadd        qword ptr [esp+40h] 
0111104C  fstp        qword ptr [esp] 
0111104F  call        dword ptr [__imp_std::basic_ostream&lt;char,std::char_traits&lt;char&gt; &gt;::operator&lt;&lt; (1112040h)]
</code></pre>
<p>vorhin konnte ich ja zumindest noch raten, was was heißt - aber jz wirst du wohl mal nen paar worte dazu sagen müssen - bitte <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f921.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--clown_face"
      title=":clown:"
      alt="🤡"
    /></p>
<p>bb</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1687492</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1687492</guid><dc:creator><![CDATA[unskilled]]></dc:creator><pubDate>Sat, 28 Mar 2009 15:23:09 GMT</pubDate></item><item><title><![CDATA[Reply to array um die x-achse spiegeln on Sat, 28 Mar 2009 16:09:05 GMT]]></title><description><![CDATA[<p>ich habe ein bißchen Zeiten gemessen mit</p>
<pre><code class="language-cpp">int main()
{
	clock_t start=clock();
	double sum=0;
	double t=0;
	double const sizeYm=4;
	for(unsigned int i=0;i&lt;4000000000u;++i){
		double y=++t;
		double x=++t;
//		sum+= (sizeY-y-1)*sizeX+x;
//		sum+= ((sizeY-1)-y)*sizeX+x;
		sum+= (sizeYm-y)*sizeX+x;
	}
	clock_t end=clock();
    cout &lt;&lt; sum &lt;&lt; '\n';
    cout &lt;&lt; (end-start)/double(CLOCKS_PER_SEC) &lt;&lt; '\n';
}
</code></pre>
<p>und stelle fest: ich kann keinen zeitunterschied feststellen.</p>
<p>trotdem bleibe ich vermutlich dabei, hin und wieder theoretisch notzlose klammen zu setzen.</p>
<pre><code class="language-cpp">int main()
{
    double a=1e20;
    cout &lt;&lt; (1+a-a) &lt;&lt; '\n';
    cout &lt;&lt; (a+1-a) &lt;&lt; '\n';
    cout &lt;&lt; (a-a+1) &lt;&lt; '\n';
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1687519</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1687519</guid><dc:creator><![CDATA[volkard]]></dc:creator><pubDate>Sat, 28 Mar 2009 16:09:05 GMT</pubDate></item><item><title><![CDATA[Reply to array um die x-achse spiegeln on Sat, 28 Mar 2009 16:27:27 GMT]]></title><description><![CDATA[<p>volkard schrieb:</p>
<blockquote>
<pre><code class="language-cpp">int main()
{
    double a=1e20;
    cout &lt;&lt; (1+a-a) &lt;&lt; '\n';
    cout &lt;&lt; (a+1-a) &lt;&lt; '\n';
    cout &lt;&lt; (a-a+1) &lt;&lt; '\n';
}
</code></pre>
</blockquote>
<p>ok - nur, dass es darum gerade nich ging ^^ ;P</p>
<p>bb</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1687527</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1687527</guid><dc:creator><![CDATA[unskilled]]></dc:creator><pubDate>Sat, 28 Mar 2009 16:27:27 GMT</pubDate></item></channel></rss>