Game Development Community

Basic Geometry Question

by rennie moffat · in iTorque 2D · 10/06/2011 (6:57 pm) · 4 replies

Hi there,
sorry to post here, but I dont know where else to ask... I have looked online but I am wracking my brain. I am trying to find an angle in a right angle triangle. Specifically, my hero position is one position, and I can touch anywhere on the screen. This touch, calculates the other point. I figure I can add the x and y values to get and use mTan(rise, run) to calculate the angle on which the hypothenus runs out from the hero, up to the touch point. However, nothing seems to be working... well it kinda seemed to be working on the iTGB test platform, but in XCode, on the device, I get the message...

scripts/behaviors/travellerBtnTrigger_behavior.cs (233): ::mTan - wrong number of arguments.
scripts/behaviors/travellerBtnTrigger_behavior.cs (233): usage: ( val ) Use the mTan function to get the tangent of the radian angle val.
@param val A value between -3.14159/2 and 3.14159/2.
@return Returns the tangent of val. This value will be in the range [ -inf.0 , inf.0 ].
@sa mAtan

into my mTan() I am putting rise = float number, example 38.222, and run for example 32.322.

Any ideas? Thanks.

About the author

My thanks to Garage Games and the Garage Games Community combined with owned determination I got one game up, Temple Racer and I am looking to build more interesting, fun games for the mass market of the iOS app store.


#1
10/06/2011 (7:02 pm)
how did your code look and did you correctly divide process it through multiplication with PI / 360 to get it from degree to half radians?
#2
10/06/2011 (7:05 pm)
I am not sure. What does this say to you?


///////////////////////////////////////
	//////////////////////////////////////
	//calculate rotation
   	%aPt = %this.ogTouchPt.x SPC %this.ogTouchPt.y;
   	%bPt = $hero.position;
   	///	///rise	///run
   	%rise = %aPt.y + %bPt.y;
   	%run = %aPt.x + %bPt.x;
   	%angle = mTan(%rise, %run);
   	echo("trvlr::wpnRealm:: $hero.position " @ $hero.position);
   	echo("trvlr::wpnRealm:: %aPt.y " @ %aPt.y);
   	echo("trvlr::wpnRealm:: %bPt.y " @ %bPt.y);
   	echo("trvlr::wpnRealm:: %aPt.x " @ %aPt.x);
   	echo("trvlr::wpnRealm:: %bPt.x " @ %bPt.x); 
   	echo("trvlr::wpnRealm:: %rise " @ %rise); 
   	echo("trvlr::wpnRealm:: %run " @ %run); 	
   	echo("trvlr::wpnRealm:: %angle " @ %angle);
#3
10/07/2011 (8:18 am)
that you use the wrong function ;)
Tan is to get the tanges of angle, but what you try to get is the angle basing on the tangens which would be Arcus Tangens (mATan in Torque if I recall right) because mTan(%angle) = %rise / %run -> %angle = mATan(%rise/%run)
#4
10/07/2011 (8:52 am)
edit:
oops.
keep you posted.