<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
<title>Calculating the angle of a point in relation to another</title>
<description>So I&#039;m started coding up a simple 3d racing game and I am trying to figure out how to turn.

I have 2 vectors;

float player_position[3] = {0,0,0};
float player_direction[3] = {0,0,1000};

I want to change the player_direction vector by an angle example 60 degrees to the right or left of its current position. Whats the simplest way to calculate the new point in c?</description><link>http://forum.wiibrew.org/read.php?11,69206,69206#msg-69206</link><lastBuildDate>Sun, 13 Sep 2026 13:53:01 +0200</lastBuildDate>
<generator>Phorum 5.2.23</generator>
<item>
<guid>http://forum.wiibrew.org/read.php?11,69206,70692#msg-70692</guid>
<title>Re: Calculating the angle of a point in relation to another</title><link>http://forum.wiibrew.org/read.php?11,69206,70692#msg-70692</link><description><![CDATA[ finally managed to put the code to some good use; [<a href="http://wiibrew.org/wiki/Newo_Model_Viewer" rel="nofollow">wiibrew.org</a>]]]></description>
<dc:creator>owen</dc:creator>
<category>Coding</category><pubDate>Sun, 10 Jun 2012 09:09:44 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,69206,70040#msg-70040</guid>
<title>Re: Calculating the angle of a point in relation to another</title><link>http://forum.wiibrew.org/read.php?11,69206,70040#msg-70040</link><description><![CDATA[ I always get distracted when I get some new code to play with, lol, but I am making a centipede/snake demo game using the code (not finished yet). I also wrote a blog post describing how I use the function for <a href="http://newogame.posterous.com/simple-aabb-collision-detection" rel="nofollow">simple AABB collision detection</a>.<br />I will upload the centipede demo and source to wiibrew as soon as I finish it.]]></description>
<dc:creator>owen</dc:creator>
<category>Coding</category><pubDate>Thu, 22 Mar 2012 16:52:58 +0100</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,69206,69976#msg-69976</guid>
<title>Re: Calculating the angle of a point in relation to another</title><link>http://forum.wiibrew.org/read.php?11,69206,69976#msg-69976</link><description><![CDATA[ With the final touch by Titmouse. I think that after 2 months it is finally working! with z roll and everything! I am going to have to create a neat little demo and put it on wiibrew. Just a little more bug testing to do!<br /><br />here are the raw functions;<br /><br /><pre class="bbcode">

guVector rotate_vector_to_angle( guVector player_target, guVector player_position, float angx, float angy, float angz ){

	static  guVector  _GRRaxisx = (guVector){1, 0, 0}; // DO NOT MODIFY!!!
	static  guVector  _GRRaxisy = (guVector){0, 1, 0}; // Even at runtime
	static  guVector  _GRRaxisz = (guVector){0, 0, 1}; // NOT ever!

	Mtx g_ObjTransformationMtx;  //hack ... moved into gloabal space
    Mtx m, rx,ry,rz;
    Mtx mv, mvi;

    guMtxIdentity(g_ObjTransformationMtx);

	//if((scalx !=1.0f) || (scaly !=1.0f) || (scalz !=1.0f)) {
        guMtxIdentity(m);
		guMtxScaleApply(m, m, 1,  1, 1);   //no need to scale.  scale is always 1
        guMtxConcat(m, g_ObjTransformationMtx, g_ObjTransformationMtx);    
	//}

    if((angx !=0.0f) || (angy !=0.0f) || (angz !=0.0f)) {
        guMtxIdentity(m);
        guMtxRotAxisDeg(rx, &_GRRaxisx, angx);
        guMtxRotAxisDeg(ry, &_GRRaxisy, angy);
        guMtxRotAxisDeg(rz, &_GRRaxisz, angz);
        guMtxConcat(ry, rx, m);
        guMtxConcat(m, rz, m);
        guMtxConcat(m, g_ObjTransformationMtx, g_ObjTransformationMtx);
	}

	//if((player_position.x !=0.0f) || (player_position.y !=0.0f) || (player_position.y !=0.0f)) {
		guMtxIdentity(m);
		guMtxTransApply(m, m, player_position.x, player_position.y, player_position.z);  //always done
		guMtxConcat(m, g_ObjTransformationMtx, g_ObjTransformationMtx);
	//}

	guVector orig_direction = player_target;
	
	guMtxApplyTrans (g_ObjTransformationMtx, g_ObjTransformationMtx, -player_position.x, -player_position.y, -player_position.z);
	guVecMultiply(g_ObjTransformationMtx, &orig_direction, &player_target);
 
	return player_target;  //returns the new location of the target location

}

guVector tracker_get_degrees_to_face_target(guVector current, guVector target ) {
	//it calculates the angle needed for the [model] to face the target from current_position
	
	float dx=target.x-current.x;
	float dy=target.y-current.y;
	float dz=target.z-current.z;

	float hyp = sqrt(dx*dx + dz*dz);

	float rx= atan2(dy, hyp);
	float ry= atan2(dx, dz);

	rx= rx * 57.2957795;
	ry= ry * 57.2957795;	
	
	return (guVector){rx, ry, 0};  //no z necessary
}	
</pre>]]></description>
<dc:creator>owen</dc:creator>
<category>Coding</category><pubDate>Sat, 17 Mar 2012 17:18:32 +0100</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,69206,69959#msg-69959</guid>
<title>Re: Calculating the angle of a point in relation to another</title><link>http://forum.wiibrew.org/read.php?11,69206,69959#msg-69959</link><description><![CDATA[ Took me forever to hack together the demo showing the problem but I am pleased to say I have it for download here; [<a href="http://www.box.com/s/712f6018458120127b0a" rel="nofollow">www.box.com</a>]<br /><br />Its a devkitpro grrlib project with 700 lines of C code. When you run it you will see a white box and a red box. The red box is the target which you can move. The white box is always facing the red box. I draw a green box at each end of the cube by using the function <b>rotate_vector_to_angle()</b> to dynamically determine where the corners of the cube are based on the rotation values of the player cube.<br /><br />The problem shows up when you press 2 and I start to apply a Z roll to the white box. X, Y rotations are OK. However Z roll is not working as I hoped. ANY help with fixing the <b>rotate_vector_to_angle()</b> function will be appreciated.]]></description>
<dc:creator>owen</dc:creator>
<category>Coding</category><pubDate>Fri, 16 Mar 2012 05:10:04 +0100</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,69206,69956#msg-69956</guid>
<title>Re: Calculating the angle of a point in relation to another</title><link>http://forum.wiibrew.org/read.php?11,69206,69956#msg-69956</link><description><![CDATA[ Yes the GameLogic::GunTurretLogic() has gotten big, don&#039;t think encapsulation it the right word (as the function makes use of classes). More a case of me being lazy and not breaking up the complexity, it is in need of a refactor (but that will never happen). It was originally under 1/2 the size – then I added bullets because it reused calculations and saved having to iterate the list all over again.<br /><br />Forget most of what you see in my code, just hunt for the “gu” calls, since it’s all piled into one function it should in this case be easier to pull apart. Granted if you’re not use to seeing container access via iterators it can look odd.<br /><br />For the bullet I use the same rotations as the original 3d turret object.<br />guMtxConcat(mat,mat2,Model); .. gives me the model rotation matrix<br />guVecMultiply(Model,...) give this your point you need checking (relative to the model) &lt;-- this part is the key<br />move it to your needed world position .... so by the time I call pShot.AddPos( ...) I have the needed coordinates to fire from no matter where it faces.<br /><br />Agreed my code is not the best place to pick up tips. ( nice vid - you clean that room! )<br /><br /><i>(did you say you will be releasing some code with the same example - that would help)</i>]]></description>
<dc:creator>Titmouse</dc:creator>
<category>Coding</category><pubDate>Thu, 15 Mar 2012 22:00:17 +0100</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,69206,69952#msg-69952</guid>
<title>Re: Calculating the angle of a point in relation to another</title><link>http://forum.wiibrew.org/read.php?11,69206,69952#msg-69952</link><description><![CDATA[ #define guMtxRotDeg(mt,axis,deg) guMtxRotRad(mt,axis,DegToRad(deg))<br />#define guMtxRotAxisDeg(mt,axis,deg) guMtxRotAxisRad(mt,axis,DegToRad(deg))]]></description>
<dc:creator>Titmouse</dc:creator>
<category>Coding</category><pubDate>Thu, 15 Mar 2012 20:58:23 +0100</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,69206,69946#msg-69946</guid>
<title>Re: Calculating the angle of a point in relation to another</title><link>http://forum.wiibrew.org/read.php?11,69206,69946#msg-69946</link><description><![CDATA[ whats the difference between guMtxRotAxisDeg(); and guMtxRotDeg(); ? they seem like the same thing with different parameters.]]></description>
<dc:creator>owen</dc:creator>
<category>Coding</category><pubDate>Thu, 15 Mar 2012 16:32:53 +0100</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,69206,69907#msg-69907</guid>
<title>Re: Calculating the angle of a point in relation to another</title><link>http://forum.wiibrew.org/read.php?11,69206,69907#msg-69907</link><description><![CDATA[ @titmouse I see your rotation code but its not encapsulated, its doing too many things at the same time. I am currently coding up a small demo so you can see how I am using the code. The function is ONLY doing barrel rolls on the -Z access (http://youtu.be/L5uTi3xs9EY). I need barrel rolls on the axis that the model is facing. I think I need to do the barrel roll after I calculate the new position_vec but I am not sure how to hack the matrix functions to achieve it.]]></description>
<dc:creator>owen</dc:creator>
<category>Coding</category><pubDate>Tue, 13 Mar 2012 22:37:17 +0100</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,69206,69876#msg-69876</guid>
<title>Re: Calculating the angle of a point in relation to another</title><link>http://forum.wiibrew.org/read.php?11,69206,69876#msg-69876</link><description><![CDATA[ I see, think I have something close. Take a look at my bolt thrower code, void GameLogic::GunTurretLogic()<br />look for something like // use bone points for both turret barrels. Allows shots to fired out the end of the barrel in 3D.<br />GameLogic::GunTurretShotsLogic does the detection (I use radius detection) this does 2D detection, ignores z. But the shots are moving on screen in 3D its just final logic check that ingores the z part since the bad ships are on a flat plan and I can optimised it be ignoring z.<br />(I placed some extra points into my 3d model dedicated to detection - in my case firing from barrel end. You can see the turrent in the intro or latter on in the game)]]></description>
<dc:creator>Titmouse</dc:creator>
<category>Coding</category><pubDate>Sun, 11 Mar 2012 10:35:17 +0100</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,69206,69874#msg-69874</guid>
<title>Re: Calculating the angle of a point in relation to another</title><link>http://forum.wiibrew.org/read.php?11,69206,69874#msg-69874</link><description><![CDATA[ @Titmouse you the function works, it solves a different problem. This function is moving points - not calculating angles.<br /><br />Here is a video of the problem; [<a href="http://youtu.be/L5uTi3xs9EY" rel="nofollow">youtu.be</a>] in the video; The cyan boxes are the things that I am rotating (for collision detection). In order for the my simple collision detection to work properly I have to be able to follow the roll animation of the plane as close as possible. If you look closely at the plane you will see that it is rolling around an axis which is created when it faces its direction vector. The error now is the Z roll is not using the same axis.]]></description>
<dc:creator>owen</dc:creator>
<category>Coding</category><pubDate>Sat, 10 Mar 2012 19:50:47 +0100</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,69206,69872#msg-69872</guid>
<title>Re: Calculating the angle of a point in relation to another</title><link>http://forum.wiibrew.org/read.php?11,69206,69872#msg-69872</link><description><![CDATA[ Owen, Not sure if you are aiming for the thing as the example I gave in this same thread (posted January 28, 2012 12:10PM)<br /><br />Keep in mind you can simplify your code - remove the first guMtxIdentity and last guMtxConcat (and use something like single param guMtxTrans so no need for identity)<br />Note that guMtxApplyTrans and guMtxTransApply <u>do not</u> do the same thing. (is guMtxApplyTrans what you need?)<br /><br />Maybe you just need to call guMtxTransApply once after the rotations. (or do you really want to translate, rotate and translate again in that order, looks odd to me) Also not sure why you are using the guVecMultiply?<br /><br />Take another look at my example - I think that&#039;s what you’re after.]]></description>
<dc:creator>Titmouse</dc:creator>
<category>Coding</category><pubDate>Sat, 10 Mar 2012 10:15:56 +0100</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,69206,69819#msg-69819</guid>
<title>Re: Calculating the angle of a point in relation to another</title><link>http://forum.wiibrew.org/read.php?11,69206,69819#msg-69819</link><description><![CDATA[ Hey guys, how you all are well. I came across another problem while I was doing collision detection. The function (shown below) works well when rotating around X and Y. It works by moving the position_vec z around the center point by rot_deg_x and rot_deg_y.<br /><br />However if I try to rotate around the Z it fails. What happens is that the Z rotation is ALWAYS around the same direction axis. I want the Z/roll rotation to be around the NEW direction which is created by the X, Y rotation.<br /><br /><pre class="bbcode">
guVector rotate_vec_to_angle( guVector position_vec, guVector center_vec, float rot_deg_x, float rot_deg_y, float rot_deg_z ) {
	guVector orig_direction = position_vec;

	Mtx m,om;
	guMtxIdentity(m);
	guMtxApplyTrans (m, om, -center_vec.x, -center_vec.y, -center_vec.z);

	guMtxRotDeg(m, &#039;x&#039;, rot_deg_x); // rotate around y axis
	guMtxConcat(m, om, om);
	guMtxRotDeg(m, &#039;y&#039;, rot_deg_y); // rotate around x axis
	guMtxConcat(m, om, om);
	guMtxRotDeg(m, &#039;z&#039;, rot_deg_z); // rotate around z axis
	guMtxConcat(m, om, om);

	guMtxIdentity(m);
	guMtxApplyTrans (m, m, center_vec.x, center_vec.y, center_vec.z);
	guMtxConcat(m, om, om);

	guVecMultiply(om, &orig_direction, &position_vec);

	return position_vec;
}</pre><br />I tried moving the Z rotation to below the VecMultiply but I can&#039;t figure out how to get it to ROLL around the new direction.]]></description>
<dc:creator>owen</dc:creator>
<category>Coding</category><pubDate>Sun, 04 Mar 2012 02:04:07 +0100</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,69206,69624#msg-69624</guid>
<title>Re: Calculating the angle of a point in relation to another</title><link>http://forum.wiibrew.org/read.php?11,69206,69624#msg-69624</link><description><![CDATA[ Owen, my mind is probably playing tricks with me – think a while back you said you might use the C++ compiler on plain C code to get nice things like strings for free, that sounded like great plan for starters.<br />( when you feel ready giving containers a go - honestly you would love them, saving huge amounts of time buy using them and they cut down on bugs! Arrays really are nasty things of foul ilk. )]]></description>
<dc:creator>Titmouse</dc:creator>
<category>Coding</category><pubDate>Mon, 13 Feb 2012 23:41:34 +0100</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,69206,69623#msg-69623</guid>
<title>Re: Calculating the angle of a point in relation to another</title><link>http://forum.wiibrew.org/read.php?11,69206,69623#msg-69623</link><description><![CDATA[ <blockquote class="bbcode"><div><small>Quote<br /></small><strong>Titmouse</strong><br />Owen, have a think about using C++ & STL containers - lends itself well to things like that.</div></blockquote><br />I am still hacking away at c. Not ready to make the C++ jump yet. I&#039;m trying to keep everything nice and tight so I&#039;m going to put the flight paths/patterns in an array of structs.]]></description>
<dc:creator>owen</dc:creator>
<category>Coding</category><pubDate>Mon, 13 Feb 2012 19:11:21 +0100</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,69206,69622#msg-69622</guid>
<title>Re: Calculating the angle of a point in relation to another</title><link>http://forum.wiibrew.org/read.php?11,69206,69622#msg-69622</link><description><![CDATA[ Owen, have a think about using C++ & STL containers - lends itself well to things like that.]]></description>
<dc:creator>Titmouse</dc:creator>
<category>Coding</category><pubDate>Mon, 13 Feb 2012 18:36:56 +0100</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,69206,69620#msg-69620</guid>
<title>Re: Calculating the angle of a point in relation to another</title><link>http://forum.wiibrew.org/read.php?11,69206,69620#msg-69620</link><description><![CDATA[ I plan to do enemy patterns similar to these; [<a href="http://www.youtube.com/watch?v=AaDujdGq4yI" rel="nofollow">www.youtube.com</a>]]]></description>
<dc:creator>owen</dc:creator>
<category>Coding</category><pubDate>Mon, 13 Feb 2012 17:14:09 +0100</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,69206,69609#msg-69609</guid>
<title>Re: Calculating the angle of a point in relation to another</title><link>http://forum.wiibrew.org/read.php?11,69206,69609#msg-69609</link><description><![CDATA[ <blockquote class="bbcode"><div><small>Quote<br /></small><strong>Titmouse</strong><br />tueidj - I see, thanks for the info.<br /><br />Sorry Owen, hitting your thread a bit hard now wth off subject matters ;)</div></blockquote><br />No problem I got the answers that I were looking for, my enemy ships are flying along a nice flight path now. All I have left to do now is draw the paths.]]></description>
<dc:creator>owen</dc:creator>
<category>Coding</category><pubDate>Mon, 13 Feb 2012 00:49:28 +0100</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,69206,69608#msg-69608</guid>
<title>Re: Calculating the angle of a point in relation to another</title><link>http://forum.wiibrew.org/read.php?11,69206,69608#msg-69608</link><description><![CDATA[ tueidj - I see, thanks for the info.<br /><br />Sorry Owen, hitting your thread a bit hard now wth off subject matters ;)]]></description>
<dc:creator>Titmouse</dc:creator>
<category>Coding</category><pubDate>Mon, 13 Feb 2012 00:43:23 +0100</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,69206,69607#msg-69607</guid>
<title>Re: Calculating the angle of a point in relation to another</title><link>http://forum.wiibrew.org/read.php?11,69206,69607#msg-69607</link><description><![CDATA[ wilco2009 - I&#039;ll keep a look out for your space shooter in the near future, must admit I&#039;m starting a 3D shooter myself, based kind of on the 3D intro scene from my Bolt Thrower game.<br />I&#039;m just pondering on using quaternions (I think rather than say changing Up, Right and Front ) since I&#039;ll have all types of camera views, gimbal lock in general will be an issue for me.<br /><br />Yes I would indeed like to see your working code - drop me a line at <a href="mailto:&#116;&#105;&#116;&#109;&#111;&#117;&#115;&#101;&#48;&#48;&#49;&#64;&#103;&#109;&#97;&#105;&#108;&#46;&#99;&#111;&#109;">&#116;&#105;&#116;&#109;&#111;&#117;&#115;&#101;&#48;&#48;&#49;&#64;&#103;&#109;&#97;&#105;&#108;&#46;&#99;&#111;&#109;</a>]]></description>
<dc:creator>Titmouse</dc:creator>
<category>Coding</category><pubDate>Mon, 13 Feb 2012 00:33:45 +0100</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,69206,69587#msg-69587</guid>
<title>Re: Calculating the angle of a point in relation to another</title><link>http://forum.wiibrew.org/read.php?11,69206,69587#msg-69587</link><description><![CDATA[ <blockquote class="bbcode"><div><small>Quote<br /></small><strong>Titmouse</strong><br />wilco2009 – do you have any open projects (i.e. shared Google code) with these techniques. (your wii brew link is blocked)<br />Things like guVecScale(&player_front, &player_front, -1); // to flip, is something I would not thought of doing, obvious now I&#039;ve seen it!<br />Infact I&#039;ve never though about changing things like the up,left vectors, to alow for 360 rotation without issues!</div></blockquote>
As Owen says you can take a look to the 11th part of my course. The only thing it is in Spanish.<br />I haven&#039;t any active source in google code.<br />I&#039;m developing improvements in the source code of the course. My idea is to make a space war shooter.<br />I could share my code with you, no problem for that.]]></description>
<dc:creator>wilco2009</dc:creator>
<category>Coding</category><pubDate>Sat, 11 Feb 2012 17:27:25 +0100</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,69206,69586#msg-69586</guid>
<title>Re: Calculating the angle of a point in relation to another</title><link>http://forum.wiibrew.org/read.php?11,69206,69586#msg-69586</link><description><![CDATA[ <blockquote class="bbcode"><div><small>Quote<br /></small><strong>Titmouse</strong><br />Array & functions yes - but structures using pointers for you? (just checked guVector is a struct), new one on me! that would break C.<br /><br />Is it in some way marked as an array, hidden away somewhere - I&#039;ve yet to see this How does it do this???</div></blockquote>
C is only a language specification, it has nothing to do with how the ABI is defined. A struct is simply a fixed size array that is allowed to have different sized elements. If it&#039;s declared const or the function doesn&#039;t modify it there&#039;s no need to create a temporary copy.]]></description>
<dc:creator>tueidj</dc:creator>
<category>Coding</category><pubDate>Sat, 11 Feb 2012 16:46:19 +0100</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,69206,69585#msg-69585</guid>
<title>Re: Calculating the angle of a point in relation to another</title><link>http://forum.wiibrew.org/read.php?11,69206,69585#msg-69585</link><description><![CDATA[ <blockquote class="bbcode"><div><small>Quote<br /></small><strong>Titmouse</strong><br />wilco2009 – do you have any open projects (i.e. shared Google code) with these techniques. (your wii brew link is blocked)<br />Things like guVecScale(&player_front, &player_front, -1); // to flip, is something I would not thought of doing, obvious now I&#039;ve seen it!<br />Infact I&#039;ve never though about changing things like the up,left vectors, to alow for 360 rotation without issues!</div></blockquote><br />have you seen his tutorial 11? its like a freespace, source included. you have to translate the page though; [<a href="http://wii.scenebeta.com/tutorial/curso-aplicado-de-grrlib-11o-entrega" rel="nofollow">wii.scenebeta.com</a>] video of it; [<a href="http://www.youtube.com/watch?v=75r7ODa7C8Y&feature=player_embedded" rel="nofollow">www.youtube.com</a>]]]></description>
<dc:creator>owen</dc:creator>
<category>Coding</category><pubDate>Sat, 11 Feb 2012 14:37:51 +0100</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,69206,69583#msg-69583</guid>
<title>Re: Calculating the angle of a point in relation to another</title><link>http://forum.wiibrew.org/read.php?11,69206,69583#msg-69583</link><description><![CDATA[ Owen, for a asteroids you only need to spin arround two axis. (think you know that)<br />What you have looks spot on - just leave one spin axis as zero.]]></description>
<dc:creator>Titmouse</dc:creator>
<category>Coding</category><pubDate>Sat, 11 Feb 2012 14:27:06 +0100</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,69206,69582#msg-69582</guid>
<title>Re: Calculating the angle of a point in relation to another</title><link>http://forum.wiibrew.org/read.php?11,69206,69582#msg-69582</link><description><![CDATA[ wilco2009 – do you have any open projects (i.e. shared Google code) with these techniques. (your wii brew link is blocked)<br />Things like guVecScale(&player_front, &player_front, -1); // to flip, is something I would not thought of doing, obvious now I&#039;ve seen it!<br />Infact I&#039;ve never though about changing things like the up,left vectors, to alow for 360 rotation without issues!]]></description>
<dc:creator>Titmouse</dc:creator>
<category>Coding</category><pubDate>Sat, 11 Feb 2012 14:21:57 +0100</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,69206,69581#msg-69581</guid>
<title>Re: Calculating the angle of a point in relation to another</title><link>http://forum.wiibrew.org/read.php?11,69206,69581#msg-69581</link><description><![CDATA[ @titmouse yeah I know about gimbal lock but its a matrix operation shouldn&#039;t it work fine? I am just going to be spinning asteroids so it may not be much of a problem for me if it gimbal locks. (collision detection will be the next problem, probably should start another thread)]]></description>
<dc:creator>owen</dc:creator>
<category>Coding</category><pubDate>Sat, 11 Feb 2012 14:18:31 +0100</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,69206,69580#msg-69580</guid>
<title>Re: Calculating the angle of a point in relation to another</title><link>http://forum.wiibrew.org/read.php?11,69206,69580#msg-69580</link><description><![CDATA[ Owen, same thing as my example code post to this thread on January 28, 2012 12:10PM (I optimized a little and has things like scaling too)<br />But yes it looks like it should work fine.<br /><u>Please note:</u> You will need to read up on gimbal lock - this method will fail if you use it the wrong way!!!]]></description>
<dc:creator>Titmouse</dc:creator>
<category>Coding</category><pubDate>Sat, 11 Feb 2012 13:37:28 +0100</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,69206,69574#msg-69574</guid>
<title>Re: Calculating the angle of a point in relation to another</title><link>http://forum.wiibrew.org/read.php?11,69206,69574#msg-69574</link><description><![CDATA[ @wilco2009 That is advanced stuff! I hope you are still working on that example program.<br /><br />@titmouse here is the current vector point rotation function based on wilco&#039;s code. try this function to see if it works for you;<br /><pre class="bbcode">
guVector rotate_vec_to_angle( guVector position_vec, guVector center_vec, float rot_deg_x, float rot_deg_y, float rot_deg_z ) {
	guVector orig_direction = position_vec;

	Mtx m,om;
	guMtxIdentity(m);
	guMtxApplyTrans (m, om, -center_vec.x, -center_vec.y, -center_vec.z);

	guMtxRotDeg(m, &#039;x&#039;, rot_deg_x); // rotate around y axis
	guMtxConcat(m, om, om);
	guMtxRotDeg(m, &#039;y&#039;, rot_deg_y); // rotate around x axis
	guMtxConcat(m, om, om);
	guMtxRotDeg(m, &#039;z&#039;, rot_deg_z); // rotate around z axis
	guMtxConcat(m, om, om);

	guMtxIdentity(m);
	guMtxApplyTrans (m, m, center_vec.x, center_vec.y, center_vec.z);
	guMtxConcat(m, om, om);

	guVecMultiply(om, &orig_direction, &position_vec);

	return position_vec;
}
</pre>]]></description>
<dc:creator>owen</dc:creator>
<category>Coding</category><pubDate>Fri, 10 Feb 2012 22:10:01 +0100</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,69206,69573#msg-69573</guid>
<title>Re: Calculating the angle of a point in relation to another</title><link>http://forum.wiibrew.org/read.php?11,69206,69573#msg-69573</link><description><![CDATA[ Array & functions yes - but structures using pointers for you? (just checked guVector is a struct), new one on me! that would break C.<br /><br />Is it in some way marked as an array, hidden away somewhere - I&#039;ve yet to see this How does it do this???]]></description>
<dc:creator>Titmouse</dc:creator>
<category>Coding</category><pubDate>Fri, 10 Feb 2012 21:52:58 +0100</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,69206,69568#msg-69568</guid>
<title>Re: Calculating the angle of a point in relation to another</title><link>http://forum.wiibrew.org/read.php?11,69206,69568#msg-69568</link><description><![CDATA[ That won&#039;t really change anything, if you look at the compiler&#039;s output you&#039;ll find it already passes the input and output vectors using pointers.]]></description>
<dc:creator>tueidj</dc:creator>
<category>Coding</category><pubDate>Fri, 10 Feb 2012 17:11:18 +0100</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,69206,69567#msg-69567</guid>
<title>Re: Calculating the angle of a point in relation to another</title><link>http://forum.wiibrew.org/read.php?11,69206,69567#msg-69567</link><description><![CDATA[ good tips from wilco2009<br />Owen, small speed up for you... (I&#039;ve left the return by value as is)<br /><br /><i>Code snip...</i><pre class="bbcode">
guVector get_rotation_degrees_to_face_target(guVector* pCurrent, guVector* pTarget ) {
	float dx = pTarget-&gt;x - pCurrent-&gt;x;
	float dy = pTarget-&gt;y - pCurrent-&gt;y;
	float dz = pTarget-&gt;z - pCurrent-&gt;z;
... rest the same</pre>
<i>example calling code..</i><pre class="bbcode">
	guVector p1 = {20, 20, 20};
	guVector p2 = {-33, -33, -33};
	guVector vec = get_rotation_degrees_to_face_target(&p1, &p2);

	printf ("%f %f %f",vec.x,vec.y,vec.z );
</pre>]]></description>
<dc:creator>Titmouse</dc:creator>
<category>Coding</category><pubDate>Fri, 10 Feb 2012 15:51:56 +0100</pubDate></item>
</channel>
</rss>