News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Asin and Arcsin?

Started by Farabi, January 15, 2012, 01:13:34 AM

Previous topic - Next topic

Farabi

Is arcsin is the same with asin?
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"


Farabi

The notation is too complicated, I even know getVectorLength is the same with DotProduct.

Is what Im doing is right?


invoke Vec_Sub,addr vR,lpfPos,addr VPosa
invoke fGetVectorLen,addr vR
fstp _len

fld vR.x
fdiv _len
invoke FpuArctan,0,addr q,SRC1_FPU or DEST_MEM
fld q
fstp _d
invoke Vec_RadToDeg,_d
fstp q
invoke FloatToStr2,q,addr buff
invoke fShowText,10,50+50,addr buff


I tried to convert radian to degree, but always yield result -0 when I stored the result as a qword.
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

Farabi

Nevermind, I think I found the way. I only need to find 1 more equation.
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

qWord

Quote from: Farabi on January 15, 2012, 02:40:47 AMI even know getVectorLength is the same with DotProduct.
no

Quote from: Farabi on January 15, 2012, 02:40:47 AMI tried to convert radian to degree, but always yield result -0 when I stored the result as a qword.
deg = rad*180/pi
FPU in a trice: SmplMath
It's that simple!

raymond

Quoteinvoke FpuArctan,0,addr q,SRC1_FPU or DEST_MEM

According to the Fpulib help file:

QuoteANG_DEG      The angle will be returned in degrees
             (this is the default and does not need to be indicated)

I don't know what the other following functions perform and how they may affect the FPU registers or the memory location for q, BUT the original arctan result would have been returned in degrees since you did not specify otherwise.  :eek
When you assume something, you risk being wrong half the time
http://www.ray.masmcode.com

Farabi

Quote from: raymond on January 15, 2012, 05:01:34 AM
Quoteinvoke FpuArctan,0,addr q,SRC1_FPU or DEST_MEM

According to the Fpulib help file:

QuoteANG_DEG      The angle will be returned in degrees
             (this is the default and does not need to be indicated)

I don't know what the other following functions perform and how they may affect the FPU registers or the memory location for q, BUT the original arctan result would have been returned in degrees since you did not specify otherwise.  :eek

Hello mr raymond, Im just realized the return value is the degree, it is me with my stupidity again  :P  :cheekygreen: I did not able to open the chm file for the manuals since Radasm did not able to search for chm files.
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

raymond

You should have that chm help file in the same folder as the source code for all the functions. Also, if you don't have the latest version, you can get it from:

http://www.ray.masmcode.com/fpu.html#fpulib
When you assume something, you risk being wrong half the time
http://www.ray.masmcode.com

Farabi

Quote from: raymond on January 15, 2012, 07:14:43 PM
You should have that chm help file in the same folder as the source code for all the functions. Also, if you don't have the latest version, you can get it from:

http://www.ray.masmcode.com/fpu.html#fpulib

Thanks sir  :U
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

Farabi

As ussual, I though it could be easy. Anyone knew my mistake is?


Vector3 AngleTo(Vector3 from, Vector3 location)
{
    Vector3 angle = new Vector3();
    Vector3 v3 = Vector3.Normalize(location - from);

    angle.X = (float)Math.Asin(v3.Y);
    angle.Y = (float)Math.Atan2((double)-v3.X, (double)-v3.Z);

    return angle;
}


My Code

invoke Vec_Sub,addr vR,lpfPos,addr VPosa
invoke Vec_Normalize,addr VPosa,addr vR

fld VPosa.y
invoke FpuArcsin,0,0,SRC1_FPU or DEST_FPU
fst vR.Rotation.x
fstp q
invoke FloatToStr2,q,addr buff
invoke fShowText,10,50+15*4,addr buff

fld VPosa.x
fld VPosa.z
fpatan
;invoke FpuArctan,0,0,SRC1_FPU or DEST_FPU
fst vR.Rotation.y
fstp r2d
invoke Vec_RadToDeg,r2d
fstp q
invoke FloatToStr2,q,addr buff
invoke fShowText,10,50+15*5,addr buff
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

raymond

Quoteinvoke FpuArcsin,0,0,SRC1_FPU or DEST_FPU
fst vR.Rotation.x

Quotefpatan
;invoke FpuArctan,0,0,SRC1_FPU or DEST_FPU
fst vR.Rotation.y

Now you have vR.Rotation.x in degrees and vR.Rotation.y in radians. If you try to reuse those variables later as if they were in the same format, it will result in major errors. If you want the vR.Rotation.x in radians, use
invoke FpuArcsin,0,0,SRC1_FPU or DEST_FPU or ANG_RAD
When you assume something, you risk being wrong half the time
http://www.ray.masmcode.com

Farabi

Quote from: raymond on January 17, 2012, 05:57:13 AM
Quoteinvoke FpuArcsin,0,0,SRC1_FPU or DEST_FPU
fst vR.Rotation.x

Quotefpatan
;invoke FpuArctan,0,0,SRC1_FPU or DEST_FPU
fst vR.Rotation.y

Now you have vR.Rotation.x in degrees and vR.Rotation.y in radians. If you try to reuse those variables later as if they were in the same format, it will result in major errors. If you want the vR.Rotation.x in radians, use
invoke FpuArcsin,0,0,SRC1_FPU or DEST_FPU or ANG_RAD

about your FpuArctan, is it need 2 FPU Point occupy 2 Points on FPU stack? Since what I know, FPATAN need about 2 stack points.
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

raymond

The FpuArctan function requires the value of the tangent as its input. You would have to precompute it if you only have the x and y values.

The fpatan instruction requires both x and y to be loaded onto the top two registers of the FPU. If the tangent had already been computed, you would load it first followed by loading a 1 to the top register before using the fpatan instruction.
When you assume something, you risk being wrong half the time
http://www.ray.masmcode.com