<?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[Functions object verschachteln]]></title><description><![CDATA[<p>Hallo zusammen!</p>
<p>Kann man die folgenden &quot;transform&quot; Anweisungen irgendwie ineinander verschachteln:</p>
<pre><code class="language-cpp">#include &lt;algorithm&gt;
#include &lt;functional&gt;

using namespace std;

void myFunction() {
    double radius = 0.0;
    double center[3] = { 0, 0, 0 };
    double direction[3] = { -1, 1, 1 };

    double newCenter[3];

    transform(
          direction, 
          direction + 3, 
          newCenter, 
          bind2nd(multiplies&lt;double&gt; (), radius));
    transform(
          center, 
          center + 3, 
          newCenter,
          newCounds.center, 
          plus&lt;double&gt; ());
}
</code></pre>
<p>Die Anweisung sollte</p>
$\vec{x}_{new} = \vec{x}_{old} + r \cdot \vec{d}$

<p>implementieren.</p>
<p>Danke fuer eure Hilfe.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/274618/functions-object-verschachteln</link><generator>RSS for Node</generator><lastBuildDate>Thu, 27 Aug 2026 10:27:54 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/274618.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 29 Sep 2010 14:21:37 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Functions object verschachteln on Wed, 29 Sep 2010 14:21:37 GMT]]></title><description><![CDATA[<p>Hallo zusammen!</p>
<p>Kann man die folgenden &quot;transform&quot; Anweisungen irgendwie ineinander verschachteln:</p>
<pre><code class="language-cpp">#include &lt;algorithm&gt;
#include &lt;functional&gt;

using namespace std;

void myFunction() {
    double radius = 0.0;
    double center[3] = { 0, 0, 0 };
    double direction[3] = { -1, 1, 1 };

    double newCenter[3];

    transform(
          direction, 
          direction + 3, 
          newCenter, 
          bind2nd(multiplies&lt;double&gt; (), radius));
    transform(
          center, 
          center + 3, 
          newCenter,
          newCounds.center, 
          plus&lt;double&gt; ());
}
</code></pre>
<p>Die Anweisung sollte</p>
$\vec{x}_{new} = \vec{x}_{old} + r \cdot \vec{d}$

<p>implementieren.</p>
<p>Danke fuer eure Hilfe.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1959049</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1959049</guid><dc:creator><![CDATA[sunnyholland]]></dc:creator><pubDate>Wed, 29 Sep 2010 14:21:37 GMT</pubDate></item><item><title><![CDATA[Reply to Functions object verschachteln on Wed, 29 Sep 2010 14:36:56 GMT]]></title><description><![CDATA[<p>Mit der Standardbibliothek geht das, soweit ich weiß, nicht. Mit boost::bind bzw std::tr1::bind sollte es gehen. Ich würde mir aber einfach eine eigene Funktion für diese Operation schreiben.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1959062</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1959062</guid><dc:creator><![CDATA[krümelkacker]]></dc:creator><pubDate>Wed, 29 Sep 2010 14:36:56 GMT</pubDate></item><item><title><![CDATA[Reply to Functions object verschachteln on Wed, 29 Sep 2010 14:37:17 GMT]]></title><description><![CDATA[<p>Möglicherweise kann man das irgendwie geschickt schachteln, aber ich finde folgendes einfacher, wenn du alles in einem Schritt haben willst:</p>
<pre><code class="language-cpp">class multiply_and_add
{
private:
  double radius;
public:
  multiply_and_add(double radius): radius(radius){}
  double operator()(double lhs, double rhs)
  {
    return lhs + radius * rhs;
  }
};

void myFunction() {
    double radius = 0.0;
    double center[3] = { 0, 0, 0 };
    double direction[3] = { -1, 1, 1 };

    transform(
          center,
          center + 3,
          direction,
          newCounds.center,
          multiply_and_add(radius));
}
</code></pre>
<p>Ungetestet, sollte aber hoffentlich richtig sein.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1959064</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1959064</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Wed, 29 Sep 2010 14:37:17 GMT</pubDate></item><item><title><![CDATA[Reply to Functions object verschachteln on Wed, 29 Sep 2010 14:56:45 GMT]]></title><description><![CDATA[<p>Der Form halber hier noch die verschachtelte Version, man beachte das -3 nach dem inneren transform:</p>
<pre><code class="language-cpp">transform(
              center,
              center + 3,
              transform(
                        direction,
                        direction + 3,
                        direction,
                        bind2nd(multiplies&lt;double&gt; (), radius)) -3,
              newCounds.center,
              plus&lt;double&gt; ());
</code></pre>
<p>Zwischenergebnisse werden hier in direction gespeichert, falls dies nicht erwünscht ist, einfach was anderes einsetzen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1959071</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1959071</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Wed, 29 Sep 2010 14:56:45 GMT</pubDate></item><item><title><![CDATA[Reply to Functions object verschachteln on Wed, 29 Sep 2010 15:28:37 GMT]]></title><description><![CDATA[<p>Cool. Vielen Dank.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1959088</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1959088</guid><dc:creator><![CDATA[sunnyholland]]></dc:creator><pubDate>Wed, 29 Sep 2010 15:28:37 GMT</pubDate></item></channel></rss>