Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 49
Default Modified ACOS function

I want to modified ACOS function to display in degrees reflecting to its
quartrant.
Is there another simpler formula to replace then one I have in cell(D2)?
Sub worksample()
Range("A1") = "X"
Range("B1") = "Y"
Range("C1") = "deg"
Range("D1") = "mod. ACOS"
Range("A2") = -1
Range("B2") = -1
Range("C2") = "=DEGREES(ACOS(A2/(A2^2+B2^2)^0.5))"
Range("D2") =
"=MOD(IF(B2=0,360,IF(A20,270,IF(A2<0,90,180)))+D EGREES(ACOS(A2/(A2^2+B2^2)^0.5)),360)"
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 7,247
Default Modified ACOS function

The following code will do what you want:

Function DegreesToRadians(Degrees As Double) As Double
Const PI As Double = 3.14159265358979
DegreesToRadians = (Degrees / 360) * 2 * PI
End Function
Function RadiansToDegrees(Radians As Double) As Double
Const PI As Double = 3.14159265358979
RadiansToDegrees = 360 * Radians / (2 * PI)
End Function
Function Quadrant(Radians As Double) As Integer
Dim D As Double
D = RadiansToDegrees(Radians)
Select Case D
Case 0 To 90
Quadrant = 1
Case 91 To 180
Quadrant = 2
Case 181 To 270
Quadrant = 3
Case Else
Quadrant = 4
End Select
End Function

The DegreesToRadians function converts a number of degrees to its
radians equivalent. The RadiansToDegrees function converts radians to
degrees. The Quadrant function returns the quadrant (90 degrees
regions, starting at the X axis rotating counter-clockwise), of a
value in Radians.

If you want to compute the quadrant of a value in degrees with a
worksheet function, use

=VLOOKUP(B3,{0,1;90,2;180,3;270,4},2,TRUE)

where B3 is the value in degrees. Pay attention to the mix of commas
and semi-colons in the formula.

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)


On Sun, 2 Nov 2008 12:49:01 -0800, danpt
wrote:

I want to modified ACOS function to display in degrees reflecting to its
quartrant.
Is there another simpler formula to replace then one I have in cell(D2)?
Sub worksample()
Range("A1") = "X"
Range("B1") = "Y"
Range("C1") = "deg"
Range("D1") = "mod. ACOS"
Range("A2") = -1
Range("B2") = -1
Range("C2") = "=DEGREES(ACOS(A2/(A2^2+B2^2)^0.5))"
Range("D2") =
"=MOD(IF(B2=0,360,IF(A20,270,IF(A2<0,90,180)))+ DEGREES(ACOS(A2/(A2^2+B2^2)^0.5)),360)"
End Sub

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 8,651
Default Modified ACOS function

It isn't entirely clear what your formula is trying to do. From 0 to 180
degrees it seems to convert your X and Y into an angle in the correct
quadrant, but beyond 180 degrees it is doing something very different.
I wonder whether =MOD(DEGREES(ATAN2(A2,B2)),360) might be what you are
trying to achieve?
--
David Biddulph

"danpt" wrote in message
...
I want to modified ACOS function to display in degrees reflecting to its
quartrant.
Is there another simpler formula to replace then one I have in cell(D2)?
Sub worksample()
Range("A1") = "X"
Range("B1") = "Y"
Range("C1") = "deg"
Range("D1") = "mod. ACOS"
Range("A2") = -1
Range("B2") = -1
Range("C2") = "=DEGREES(ACOS(A2/(A2^2+B2^2)^0.5))"
Range("D2") =
"=MOD(IF(B2=0,360,IF(A20,270,IF(A2<0,90,180)))+D EGREES(ACOS(A2/(A2^2+B2^2)^0.5)),360)"
End Sub



  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 49
Default Modified ACOS function

Thank you Chip,
Thank you David,
I overlooked my formulation, cell(D2) should look like
=IF(B2<0,360-DEGREES(ACOS(A2/(A2^2+B2^2)^0.5)),DEGREES(ACOS(A2/(A2^2+B2^2)^0.5)))


"danpt" wrote:

I want to modified ACOS function to display in degrees reflecting to its
quartrant.
Is there another simpler formula to replace then one I have in cell(D2)?
Sub worksample()
Range("A1") = "X"
Range("B1") = "Y"
Range("C1") = "deg"
Range("D1") = "mod. ACOS"
Range("A2") = -1
Range("B2") = -1
Range("C2") = "=DEGREES(ACOS(A2/(A2^2+B2^2)^0.5))"
Range("D2") =
"=MOD(IF(B2=0,360,IF(A20,270,IF(A2<0,90,180)))+D EGREES(ACOS(A2/(A2^2+B2^2)^0.5)),360)"
End Sub

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 8,651
Default Modified ACOS function

That looks a lot better, and gives the same result as the much simpler ATAN2
formula which I suggested.
--
David Biddulph

"danpt" wrote in message
...
Thank you Chip,
Thank you David,
I overlooked my formulation, cell(D2) should look like
=IF(B2<0,360-DEGREES(ACOS(A2/(A2^2+B2^2)^0.5)),DEGREES(ACOS(A2/(A2^2+B2^2)^0.5)))


"danpt" wrote:

I want to modified ACOS function to display in degrees reflecting to its
quartrant.
Is there another simpler formula to replace then one I have in cell(D2)?
Sub worksample()
Range("A1") = "X"
Range("B1") = "Y"
Range("C1") = "deg"
Range("D1") = "mod. ACOS"
Range("A2") = -1
Range("B2") = -1
Range("C2") = "=DEGREES(ACOS(A2/(A2^2+B2^2)^0.5))"
Range("D2") =
"=MOD(IF(B2=0,360,IF(A20,270,IF(A2<0,90,180)))+D EGREES(ACOS(A2/(A2^2+B2^2)^0.5)),360)"
End Sub



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
"last modified" timestamp function in excel 2003 veek New Users to Excel 6 July 26th 08 05:13 AM
modified CEILING function?? Colin Foster Excel Worksheet Functions 3 April 18th 08 10:17 PM
Modified Average Function PA Excel Worksheet Functions 3 May 15th 06 12:20 PM
Date Last Modified Function Leon Excel Worksheet Functions 2 November 26th 05 10:06 PM
RANK Function Modified? Don Excel Worksheet Functions 12 March 2nd 05 09:05 PM


All times are GMT +1. The time now is 09:26 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"