Sin (radians (180)) bug in figures

I have a bug in numbers when I insert the formula

= SIN (RADIANS (180))

The result is:

0.000000000000000122464679914735

instead of exact 0.0

Anyone can reproduce the behavior?

Or is it only on my Mac and iPad bug?

And here in Excel:

Due to floating point precision arithmetic problems, nor give an exact 0.

This isn't a bug, but a reality with computers.

Not sure why the numbers is different from the result in Excel, however.

Use the ROUND function to make 0.

SG

Tags: iWork

Similar Questions

  • Access a movieclip in a native from class

    OK, so I find the classes all about confusion, but take a look at this example. A movieclip is created following the cursor, but it is created as a class.

    http://asgamer.com/2009/AS3-characte...se-with-easing

    What should I put in the normal timeline of the MouseControlled.fla file to target the character who moves around? As if I wanted to start coding some objects, it could hit that I have on the native timeline of root how to reference it?

    What is the path to the instance name?

    You can adapt an example of the timeline class by removing the package, the removal of the line of the class line, remove the "Builder" of opening and the deletion of the words "private" or "public". Also remove all brackets very closed at the end of the script and the end hence is the constructor function.

    In the case of this example, there is a line you have to add something, which is that contains the reference of the scene. Or you can replace this variable "step-by-step." In my version below I put just step in this variable.

    So, make a new movieclip on your stage of FLA, go into the movieclip and put this script under 1 timeline, then do a test movie:

    import flash.display.MovieClip;

    import flash.events. *;

    import flash.display.Stage;

    var stageRef:Stage = stage;

    var speed: Number = 10;

    x = stageRef.stageWidth / 2;

    y = stageRef.stageHeight / 2;

    this.stageRef = stageRef;

    addEventListener (Event.ENTER_FRAME, loop, false, 0, true);

    function loop(e:Event):void {}

    var yDistance:Number = stageRef.mouseY - y;

    var xDistance:Number = stageRef.mouseX - x;

    If (Math.sqrt (yDistanceyDistance + xDistancexDistance)< speed)="">

    x = stageRef.mouseX;

    y = stageRef.mouseY;

    } else {}

    var radians: Number = Math.atan2 (yDistance, xDistance);

    x += Math.cos (radian) * speed;

    y += Math.sin (radian) * speed;

    rotation = radians * 180 / Math.PI;

    }

  • gravitating round an object in motion

    Hi, I had a mc to circle around another mc (which is called a) which you can move

    but I don't know the code to make it follow the mc who can move orbiting. This is the code I have all ready


    It is on the mc dragiable this name mc's (a)

    on {(press)
    startDrag (this, false, 0, 23, 495, 407);
    }

    on (release) {}
    stopDrag();
    }

    and then on the mc which is in orbit around it

    onClipEvent (load) {}
    Ray var = 200;
    var speed = 5;

    Overview of the var = _root. a._x ;

    Var Massilia is _root. a._y ;

    degree of var = 0;
    var radians;
    }
    onClipEvent (enterFrame) {}
    degree += speed;
    Radian = (degree/180) * Math.PI;
    This ._x = xcenter + Math.cos (radian) * RADIUS;
    This ._y = Massilia - Math.sin (radian) * RADIUS;
    }

    hope someone can help

    You will need to have this change in rotation reference points when you travel 'has' around...

    onClipEvent (enterFrame) {}
    Overview = _root.a._x;
    Massilia = _root.a._y;
    degree += speed;
    Radian = (degree/180) * Math.PI;
    This ._x = xcenter + Math.cos (radian) * RADIUS;
    This ._y = Massilia - Math.sin (radian) * RADIUS;
    }

  • Master key Exploit Fix for the RAZR MAXX HD DROID?

    Hey guys,.

    I was wondering have heard of guys all the rumors of Motorola working on a difficulty to exploit for this vulernability Bluebox Security Scanner adorning my DROID RAZR MAXX HD running the Version of the 9.20.1.XT926 system. Verizon.en.US?

    BlueBox Info

    Unpatched / vulnerable to the bug 9695860

    (2nd master key/blog.sina.com.cn bug)

    Ask your provider for the update device

    Since I did some reading, this feat in the android operating system begins to be well known and risk phones eventually be diverted are it seems to have more chances. http://www.PCWorld.com/article/2045087/Symantec-spots-two-Android-apps-using-master-key-vulnerability.html#TK.fb_pc

    Thank you

    Brandon

  • example of blocking software signal in C++

    Hello

    I am new to the NC and data acquisition. Just posted this question before http://forums.ni.com/t5/Signal-Conditioning/usb-6211-DAQ-frequency-question/td-p/3202422and discovered that the signal cannot be locked on a hardware level.

    Can anyone provide an example in C / C++ to lock a 400 hz signal. I used the example of ContAcq - IntClk.c to read the data of a resolver (Sindh and cosine) and a reference signal. However as the signal moves to the right (in this case) it becomes difficult to determine the position of the resolver.

    Thank you in advance.

    Kind regards

    Gerhard

    Looks that I itself can solve another of my posts solitaire here in this forum... sort of...

    Well, since I asked for an example of code, I'll give my solution here. This is probably by far not perfect, but it works. Suggestions for improvement are welcome.

    	DAQmxErrChk (DAQmxReadAnalogF64 (taskHandle, 1000, 10.0, DAQmx_Val_GroupByChannel, data, 3000, & read, NULL));
    If (read > 0) {}
    < 2999;="">
    {
    If (data [loopa] > highestRef)
    {
    highestRef = data [loopa];
    highestPos = loopa;
    }
    }
    References = data [highestPos];
    continue = data [highestPos-1999];
    cosine = data [highestPos-999];

    radians = atan2 (cosine, continue);
    angle = radians * (180 / M_PI);

    <>
    angle += 360;

    printf ("D: %f %f Ref: %f refH: %f Pos: %i angle: %f\r", continue, references, highestRef, highestPos, cosine and angle);
    fflush (stdout);
    }

  • SetWorldTransform does not work on the actual printer

    It is a question of impression MFC Device Context.
    I need to print-90 degree rotated out of printer. I developed the following code using SetWorldTransform. The problem is that it does not turn the contents of the physical printer device context. BUT... If I save printing in printer output (.xps) file, it records and displays the content of the context of device-90 degrees correctly.

    void CMyDLL::drawReport (CDC * pDC, CPrintInfo * pInfo, bool bRotatePage)
    {
    int nGraphicsMode;
    float fWidth;
    float fHeight;
     
    bool bIsPrinting is pDC-> IsPrinting();. Just to test. This returns true.

    My drawings on the device context are here
    ... ... ...
    ... ... ...
    //////////
    If (bRotatePage)
    {
    Double pi = 3.14159265358979323846264338328;
    Double radians = (2.0 (double) * pi *-90.00 (double)) / (double) 360.0; Rotation-90 °
    XFORM xForm.
    xForm.eM11 = (float) cos (radian).
    xForm.eM12 = (float) sin (radians);
    xForm.eM21 = (float) - sin (radians);
    xForm.eM22 = (float) cos (radian).
    xForm.eDx = 0.0;
    xForm.eDy = 1000.0; just a fixed value

    nGraphicsMode = pDC-> SetGraphicsMode (GM_ADVANCED);
    SetWorldTransform (pDC-> m_hDC, &xForm);)
    pDC-> SetGraphicsMode (nGraphicsMode);

    }
    }

    I don't know why real printer does not work while printing at the exit of the printer (.xps) of the file works perfectly. Any suggestion is appreciated

    This issue is beyond the scope of this site and must be placed on Technet or MSDN

    http://social.msdn.Microsoft.com/forums/en-us/home

  • Error #2007 how to fix it?

    I am getting an error with my hitTestObject for the boss1 and I don't know how to fix it. The part that becomes the problem is blue and everthing else is fine. I tried to go on the thing degbug, and that did not help...

    package
    {

    import flash.display.MovieClip;
    import flash.events. *;
    import flash.text.TextField;
    flash.ui import. *;
    import flash.display. *;

    SerializableAttribute public class extends MovieClip Arrow
    {
    var speed: Number = 25;
    var: a game;
    var boss1:Boss1;

    public void Initialize (e: event)
    {
    This.rotation = Man.rot + 180;
    game = stage.getChildByName("root1") as game;
    boss1 = stage.getChildByName ("root2") as Boss1;
    }


    public void Arrow()
    {
    this.addEventListener (Event.ENTER_FRAME, this.) OnEnterFrame);
    this.addEventListener (Event.ADDED_TO_STAGE, this.) (Commissioning);
    }
    public void OnEnterFrame(e:Event)
    {
    x = x + Math.cos (rotation/180*Math.PI+80.1) * speed;
    y = y + Math.sin (rotation/180*Math.PI+80.1) * speed;
    If (this.y <-250) RemoveArrow();
    for (var i in game.enemyList)
    {
    If (this.hitTestObject (Game.enemyList [i]))
    {
    game.enemyList [i]. Damage (Bow.Damage);
    If (game.enemyList [i]. GetHealth() < = 0)
    {
    Man.Money += Math.ceil (Math.random () * 4) + 1;
    game.enemyList [i]. RemoveWolf1();
    game.enemyList.splice (i, 1);
    if(Man.Age == 1)
    {
    Man.kills1 += 1;
    }
    if(Man.Age == 2)
    {
    Man.kills2 += 1;
    }
    if(Man.Age == 3)
    {
    Man.kills3 += 1;
    }
    if(Man.Age == 4)
    {
    Man.kills4 += 1;
    }
    if(Man.Age == 5)
    {
    Man.kills5 += 1;
    }
    if(Man.Age == 6)
    {
    Man.kills6 += 1;
    }
    if(Man.Age == 7)
    {
    Man.kills7 += 1;
    }
    }

    RemoveArrow();
    break;
    }
    }
    (var t in game.ccheifList)
    {
    If (this.hitTestObject (Game.ccheifList [t]))
    {
    game.ccheifList [t]. Damage (Bow.Damage);
    If (game.ccheifList [t]. GetHealth() < = 0)
    {
    Man.Money += Math.ceil (Math.random () * 30) + 5;
    game.ccheifList [t]. RemoveCaveCheif();
    game.ccheifList.splice (t, 1);
    if(Man.Age == 1)
    {
    Man.kills1 += 1;
    }
    if(Man.Age == 2)
    {
    Man.kills2 += 1;
    }
    if(Man.Age == 3)
    {
    Man.kills3 += 1;
    }
    if(Man.Age == 4)
    {
    Man.kills4 += 1;
    }
    if(Man.Age == 5)
    {
    Man.kills5 += 1;
    }
    if(Man.Age == 6)
    {
    Man.kills6 += 1;
    }
    if(Man.Age == 7)
    {
    Man.kills7 += 1;
    }
    }
    RemoveArrow();
    break;
    }

    }
    If (this.hitTestObject (boss1))
    {
    Boss1.health = Bow.Damage;
    If (Boss1.health < = 0)
    {
    Man.Money += Math.ceil (Math.random () * 100) + 100;
    Boss1.Remove = true;
    }
    RemoveArrow();
    }
    for (var r in game.caveList)
    {
    If (this.hitTestObject (Game.caveList [r]))
    {
    game.caveList [r]. Damage (Bow.Damage);
    If (game.caveList [r]. GetHealth() < = 0)
    {
    Man.Money += Math.ceil (Math.random () * 10) + 5;
    game.caveList [r]. RemoveCaveMan();
    game.caveList.splice (r, 1);
    if(Man.Age == 1)
    {
    Man.kills1 += 1;
    }
    if(Man.Age == 2)
    {
    Man.kills2 += 1;
    }
    if(Man.Age == 3)
    {
    Man.kills3 += 1;
    }
    if(Man.Age == 4)
    {
    Man.kills4 += 1;
    }
    if(Man.Age == 5)
    {
    Man.kills5 += 1;
    }
    if(Man.Age == 6)
    {
    Man.kills6 += 1;
    }
    if(Man.Age == 7)
    {
    Man.kills7 += 1;
    }
    }

    RemoveArrow();
    break;
    }

    }


    }
    public void RemoveArrow()
    {
    this.removeEventListener (Event.ENTER_FRAME, this.) OnEnterFrame);
    this.removeEventListener (Event.ADDED_TO_STAGE, this.) (Commissioning);
    this.parent.removeChild (this);
    }


    }

    }

    You have a periodic function, the OnEnterFrame function, which is called over and over again. In this function, you have a hitTest for an object whose value is stored in a variable, boss1. When you remove Boss1, the value is stored in the variable boss1, the variable has no value or reference, and so the hitTestFunction generates an error. He has nothing to work with.

    So, if you take the value stored in boss1, you need to either stop the execution of the OnEnterFrame function or you will have to work around the section of the function that performs the hit test.

    Which helps explain the problem?

  • Follower of the mouse of rotation with easing

    I'm terrible at math and having a problem to reach my goal.

    http://www.newgrounds.com/dump/item/6e5cde6c6b94de74119aac82c43312d2 - example

    It works just fine, but what I want to do is have each object to follow the rotation at different speeds. I want that every MC having "Acceleration".

    I can't understand how to run a little slower than the mouse itself. As a result, just dead on, same speed as the mouse moves, it moves.

    Related to mcMouseFollower.as MovieClip class.

    I have my main class the following:

    package {}

    import flash.display. *;

    import flash.events.Event;

    SerializableAttribute public class MAIN extends MovieClip {}

    public var follower: mcMouseFollower;

    public void MAIN () {}

    the constructor code

    Tracker = new mcMouseFollower();

    Follower.x = stage.stageWidth / 2;

    Follower.y = stage.stageHeight / 2;

    stage.addChild (follower);

    stage.addEventListener (Event.ENTER_FRAME, frameLoop);

    }

    public function frameLoop (event: Event): void {}

    Check out the coordinates of the mouse to discover the angle

    var cy:Number = stage.mouseY - follower.y;

    var cx:Number = stage.mouseX - follower.x;

    var Radians: Number = Math.atan2 (cx, cy); / / Find the angle

    var degrees: Number = Radians * 180 / Math.PI;// convert to degrees of rotation

    Rotate

    Follower.rotation = degrees;

    }

    }

    }

    To do this manually, you need to find the change in rotation between the follower.rotation and the degrees of calculated. Then, you apply some of this difference. So if you want to have the rotation of the rod move 1/10 of the path to the destination of your choice each image, calculate the change in the rotation needed to point to the mouse, then multiply by 0.1 and apply this rotation changed to follower.rotation. This does not exactly work as tweens that you configure in Flash because it will not have an exact end time. Instead, each image rotation reduces the difference in new rotation of half. It will resemble an ease of exit. You can check when it is thin enough (for example, the difference is less than 1 degree) and just snap to your final rotation rather than continue to settle for halfway.

    You'll want to know how to work the degrees of rotation. Pointing to the right is 0 degrees, rotation to the right there is positive, go to 180 that points to the left. From 0 degrees and rotating timer causes the downward rotation value, entering negative numbers, from 0 to-180 (pointing to the left). So when you try to interpolate a value through the left direction you have a problem, since the numbers of jump from-180 to 180 at that time here.

    To solve this * West * problem, you detect if the rotation must be changed by more than 180 and you adjust accordingly for the direction of rotation moves the shortest distance to the rotation of the target rather than the long way around. The calculation in the SmartRotationPlugin of the packaging of GTween is a good way to handle this:

    https://code.Google.com/p/Pipoca/source/browse/trunk/classes/com/gskinner/motion/plugins/S martRotationPlugin.as? r = 9

    Here's the corrected code (starting after your calculation of degrees):

    var deltaDegrees:Number = degrees - follower.rotation;

    deltaDegrees % = 360;

    If (deltaDegrees > 180)

    {

    deltaDegrees-= 360;

    }

    ElseIf (deltaDegrees<>

    {

    deltaDegrees += 360;

    }

    Rotate

    Follower.rotation = degrees;

    Follower.rotation += deltaDegrees * 0.1;

    You can also consider using a tween as GTween for your tween engine: http://www.gskinner.com/libraries/gtween/

  • Limitation of DISTANCE to two decimal places

    I pretty much get the Google Maps API, talking to my SQL database. For the results of my research, I have SQL code:

    SELECT *, (3959 * acos (cos (radians (".")))) $POST ["latitude"]. (radians (lat)))) * cos * cos ((LNG) radians: radians (".")) $POST ["longitude"]. ")) + sin (radians (". "))" $_POST ["latitude"]. ")) * sin (radians (lat))) AS distance FROM VenuesGeocodes1 HAVING distance < 100 ORDER BY LIMIT 0, 30;"

    That works very well, but will display the distance to 15 decimal places, which is an exaggeration full.

    How can I limit that to only two decimal places? I thought I just needed to change the distance to distance (10.2), but he doesn't like it.

    If anyone can let me know what need would be much appreciated.

    Thank you.

    If you use PHP, you can do it like this:

    $grandtotal = number_format($grandtotal,2,'.',',');

  • Calling a method perhaps undefined removeMovieClip and createEmptyMovieClip.

    Hi all

    I face the error in the design of a progress bar.

    Error in this line of code (highlighted in RED):

    function clearCircles(circleArray:Array) {}

    for (var i: Number = circleArray.length - 1; i > = 0; i--) {}

    removeMovieClip (circleArray.pop ());

    }

    onEnterFrame = null;

    root.addEventListener (Event.ENTER_FRAME, null);

    }

    and

    for (i = 0; i < numCircles; i ++) {}

    Circles.push (createEmptyMovieClip("circle" + i, i));

    drawCircle(circles[i],4,0x99FF00,100);

    circles [i] ._x = centerX + Math.sin(radians * i) * RADIUS;

    circles [i] ._y = centerY + Math.cos(radians * i) * RADIUS;

    circles [i] ._alpha = i * (100 / numCircles);

    }

    Could you please help me with this?

    If you intend to work in AS3 so the problem, it is that you are using AS2 code.  If you intend to use the code you show, be sure to select AS2 version you post to and after other issues in AS2 forum.

  • Recordset filtering from another set of records

    Here's my problem in a nut shell

    I have a search page to display results based on a code postal location(lat/long) coordinated.  The first Recordset on the page has the information of generator located in the search parameters:

    < %

    Dim builder_ID__longValue

    builder_ID__longValue = '1 '.

    If (Request.Querystring("long") <>"") then

    builder_ID__longValue = Request.Querystring ("long")

    End If

    % >

    < %

    Dim builder_ID

    Dim builder_ID_cmd

    Dim builder_ID_numRows

    Set builder_ID_cmd = Server.CreateObject ("ADODB.Command")

    builder_ID_cmd. ActiveConnection = MM_home_detective_STRING

    builder_ID_cmd.CommandText = "SELECT builder_info_ID, (3959 * acos (cos (radians (39.8227054)) * cos (radians (builder_info.lat)) * cos (radians (builder_info.lng) - radians (?))))". "(+ sin (radians (39.8227054)) * sin (radians (builder_info.lat))) AS distance FROM home_detective.builder_info HAVING < 75 ORDER BY remote.

    builder_ID_cmd. Prepared = true

    builder_ID_cmd. Parameters.Append builder_ID_cmd. CreateParameter ("param1", 5, 1, -1, builder_ID__longValue) ' adDouble

    Set builder_ID = builder_ID_cmd. Run

    builder_ID_numRows = 0

    % >

    < %

    Dim Repeat1__numRows

    Dim Repeat1__index

    Repeat1__numRows = - 1

    Repeat1__index = 0

    builder_ID_numRows = builder_ID_numRows + Repeat1__numRows

    % >

    Then from there, I have another table that has the builder_ID value listed with all of the school districts they work within.

    What I want to do is to display the search results for the school district * BUT NOT SHOW THE REJOINDER VALUES * here is the code I am using

    < %

    While ((Repeat1__numRows <> 0) AND (NOT builder_ID. EOF))

    % >

    < %

    Dim school_district__MMColParam

    school_district__MMColParam = '1 '.

    If (builder_ID.fields.item ("builder_info_ID") <>"") then

    school_district__MMColParam = builder_ID.fields.item ("builder_info_ID")

    End If

    % >

    < %

    Dim school_district

    Dim school_district_cmd

    Dim school_district_numRows

    Set school_district_cmd = Server.CreateObject ("ADODB.Command")

    school_district_cmd. ActiveConnection = MM_home_detective_STRING

    school_district_cmd.CommandText = "SELECT DISTINCT school_district FROM home_detective.school_district WHERE builder_ID =?"

    school_district_cmd. Prepared = true

    school_district_cmd. Parameters.Append school_district_cmd. CreateParameter ("param1", 5, 1, -1, school_district__MMColParam) ' adDouble

    Set school_district = school_district_cmd. Run

    school_district_numRows = 0

    % >

    < div > < % = (builder_ID. Fields.Item("builder_info_ID") % of the value) >

    < % = (school_district. Fields.Item ("school_district"). % Value) >

    < / div >

    < %

    Repeat1__index = Repeat1__index + 1

    Repeat1__numRows = Repeat1__numRows-1

    builder_ID. MoveNext()

    Wend

    % >

    as you can see, displays the results, but if 2 manufacturers have the same school district, it displays this school district twice.  I want only the DISTINCT values

    any ideas?

    Large. So now, try this query that uses the previous as a subquery:

    SELECT DISTINCT FROM home_detective.school_district WHERE builder_ID IN School_district

    (SELECT builder_info_ID FROM home_detective.builder_info

    WHERE (3959 * acos (cos (radians (39.8227054)) * cos (radians (builder_info.lat)) * cos (radians (builder_info.lng) - (?) radians) + sin (radians (39.8227054)) * sin (radians (builder_info.lat))))<>

  • Need to write a function to help.

    I'm using Oracle 11 g and SQL Plus. I am a complete newbie, so I need some help here in writing a function. I guess my question is more on the writing of trigonometric functions within the service.


    latA, longA Banff, longB / / these are the four input parameters.

    Theta = longA - longB

    distX = sin (latA * PI / 180) * sin (Banff * 180 FT) + cos (latA * PI/180) * cos (Banff * PI/180) * cos (theta * PI / 180)

    Gefrierschrank = acos (distX) / / this is arc cosine

    distZ = Gefrierschrank * 180 / PI / / PI refers to the mathematical PI

    distP = distZ * 60 * 1.1515; This value should be returned. Of course do not import the names of intermediate variables.

    Help, please. Thank you.
    CREATE OR REPLACE FUNCTION fucntion_name(latA IN NUMBER, longA IN NUMBER, latB IN NUMBER, longB IN NUMBER) RETURN NUMBER
    
    IS
    pi      CONSTANT NUMBER:=3.14159;
    theta NUMBER;
    distX  NUMBER;
    distY  NUMBER;
    distZ  NUMBER;
    distP  NUMBER;
    BEGIN
    
    theta :=longA - longB;
    
    distX :=sin( latA * PI /180) * sin ( latB * PI /180) + cos ( latA * PI/180) * cos ( latB * PI/180) * cos ( theta * PI / 180);
    
    distY :=acos(distX); --this is arc cosine
    
    distZ :=distY * 180/PI;  --PI refers to the mathematical PI
    
    distP :=distZ * 60 * 1.1515; --this value should be returned. Of course the intermediate variable names don't matter.
    
    RETURN distP;
    END;
    

    Published by: Ora may 3, 2011 23:46

  • Synchronization of gyroscope problem!

    I managed to have a sample of work using the native extension of Gyroscope. I followed the following steps:

    (1) download the extension

    (2) added the DONKEY file on the library path in Flash Professional CS 5.5

    (3) coded as described in the documentation for the extensions

    (4) exported the SWF file

    (5) compiled the SWF and the extension using ADT

    I worked perfectly. I had a turned 3D cube using gyroscope data.

    Well, not exactly calibrated because after awhile app seems to have lost direction.

    But I read this is normal and you had to use the accelerator to balance it.

    I'm not worried about it even if right now.

    (6) and then I added a video DisplayObject that is attached to the camera because I need to make a game of AR.

    When I test this gyroscope data seems out of sync with the reality of the time lapse (i.e. made rotations appear seconds after)

    and this gets worse and worse when the time elapses. Perhaps the video makes gyro data for synchronization.

    Do you have an idea how overcome this problem.

    I don't know, so I can't fix it myself with the data source Objective C code.

    If you can help my kid would be great, I have a presentation demonstration Friday of this week.

    Thank you

    Nobody answered so... for those interested in the problem:

    (1) when the device is set on high rates resolution produces this Gyroscope GAL.

    (2) resolved this lower resolution 480 x 288 to 15 images/s

    This on an iPad 2, maybe it depends on memory and other things so can not work for iPad 1 or others.

    (3) could not use StageVideo. It seems that he can play only local or videos server but no camera! Adobe help please add this in the future.

    Here you have a test code to find that what I have worte in this forum is real:

    package  {
     import flash.display.Sprite;
     import com.adobe.nativeExtensions.Gyroscope;
     import flash.text.TextField;
     import flash.utils.getTimer;
     import flash.media.Video;
     import flash.media.Camera;
     import flash.display.Shape;
     import flash.events.MouseEvent;
     import flash.events.Event;
     import com.adobe.nativeExtensions.GyroscopeEvent;
     import flash.net.NetStream;
     import flash.media.StageVideo;
     import flash.events.StageVideoAvailabilityEvent;
     import flash.geom.Rectangle;
    
     public class SampleGyro extends Sprite
     {
      private var _debugTxt:TextField;
      private var _debugShape:Shape;
    
      private var _gyroscope:Gyroscope;
    
      private var _previousTime:Number;
      private var _angle:Number = 0;
    
      private var _video:Video;
      private var _camera:Camera;
    
      public function SampleGyro()
      {
       if(Gyroscope.isSupported)
       {
        _gyroscope = new Gyroscope();
        _gyroscope.addEventListener(GyroscopeEvent.UPDATE, gyroscopeHandler);
        _previousTime = getTimer();
       }
    
       stage.addEventListener(MouseEvent.CLICK, clickHandler);   
    
       _video = new Video();
       _video.visible = false;
       _video.width = stage.stageWidth;
       _video.height = stage.stageHeight;
       addChild(_video);
    
       _debugShape = new Shape();
       _debugShape.x = stage.stageWidth / 2;
       _debugShape.y = stage.stageHeight / 2;
       _debugShape.z = -10;
    
       _debugShape.graphics.beginFill(0xDD9900);
       _debugShape.graphics.drawRect(-50, -50, 100, 100);
    
       addChild(_debugShape);
    
       _debugTxt = new TextField();
       _debugTxt.width = 200;
       _debugTxt.height = 200;
       addChild(_debugTxt);
      }
    
      private function clickHandler(event:Event):void
      {
       if(_video.visible)
       {
        _video.attachCamera(null);
        _video.visible = false;
       }
       else
       {
        if(!_camera)
        {
         _camera = Camera.getCamera();
         _camera.setMode(1024, 768, _camera.fps, false);
        }
        _video.attachCamera(_camera);
        _video.visible = true;
       }
      }
      private function gyroscopeHandler(event:GyroscopeEvent)
      {
       var curTime:Number = getTimer();
       var elapsedTime:Number = (curTime - _previousTime) / 1000;
       var radians:Number = event.y * elapsedTime;
    
       _previousTime = curTime;
       _angle += radians * 180 / Math.PI;
    
       _debugTxt.text = "DEBUG\n";
       _debugTxt.appendText("rads/sec: "+event.y+"\n");
       _debugTxt.appendText("rads/tick:"+radians+"\n");
       if(_camera)
       {
        _debugTxt.appendText("camera:"+_camera.width+","+_camera.height+","+_camera.fps+"\n");
       }
    
       _debugShape.rotationY = _angle;
      }
     }
    
    }
    

    The code simply creates a square shape to see visually gyroscopic rotation

    A TextField to print the values of gyroscopic rotation Y

    And an event to listening to a single CLICK anywhere on the screen to activate the camera

    and show the video. Try several values for the dimensions of the camera and you will see

    only small (480 x 288 to 15 images/s) values will not add the question of FDA/off-synch

    Once you run the app try clicking anywhere on the screen and

    Video if poster and you will see the gyro values will come much later.

  • Figure out how to bug

    So, I understand that I can toggle the Debug button. And that is supposed to help me.

    But, I feel as if there is a reference to the fact that I don't get.

    For example, the error message says: line 7, column 1
    Who wants to help me?
    Is the column 1 column 1 on my page?
    And 7th referring to article 7?

    And, what is the trick to write longer formulas? The window is so small, I can't get a handle on my formula... you write in a text editor and copy and paste?

    Thank you
    Marion, back to my case of nesting.

    Marion,

    The error's message refers to the line 7 of the code you are running begins at column 1 of this line.

    I write, test and debug most of my code (PL/SQL and SQL) outside at the APEX and you recommend you do the same. SQL Developer is a good choice and your formatting code, long forms will be easier to read and debug.

    The f

  • Math.COS, Math.sin = Math.HELP

    Hi all

    I was hoping to create a JS script to move objects from the common center based on their current location. I thought to use an element of single selected path as the center based on its position x / y and width/height. Using this reference point that the script would then move away all other elements of the path of this central point based on a desired amount and with uniform increases, account required to their current location of this Center. I was thinking about cos and sin would be my friend in this case, but they seem to have become my enemy instead. ;-)

    Does this sound feasible? What Miss me, hurt, misinterpretation? Here's an attempt at non-working, I can't fix things, maybe I was close and missed or maybe I am so far and its complex more than I thought. However at this point I'm confused through my various attempts which is only one of them.

    Thanks in advance for any help and health mental someone can provide.

    // Example failed code, nonworking concept
    var docID = app.activeDocument;
    var s0 = docID.selection[0];
    pID = docID.pathItems;
    var xn, yn;
    var stepNum = 20;
    for (var i = 0; i < pID.length; i++) {
        var p = pID[i];
        var dx = ((s0.position[0] + s0.width) / 2 - (p.position[0] + p.width) / 2);
        var dy = ((s0.position[1] + s0.height) / 2 - (p.position[1] + p.height) / 2);
        xn = Math.cos(Number(dx) * Math.PI / 180)+stepNum;
        yn = Math.sin(Number(dy) * Math.PI / 180)+stepNum;
        var moveMatrix = app.getTranslationMatrix(xn, yn);
        p.transform(moveMatrix);
        stepNum+=stepNum;
    }
    

    Hi W_J_T, here's a way to do what I think you want to do, I put comment the increment so everything will "explode" the same distance, do not know if it is you need.

    first of all, I suggest the calculation of the center of the object selected out of the loop, you only need to do the math once.

    In addition, (s0.position[0] + s0.width) / 2 has a problem, it will not give you the Center, check below

    // calculate Selection center position
    var cx = s0.position[0] + s0.width/2;
    var cy = s0.position[1] + s0.height/2;
    

    then we're going to loop through all the elements and calculate their Center

            // calculate pathItem's center position
            var px = p.position[0] + p.width/2;
            var py = p.position[1] + p.height/2;
    

    We will pass the calculation of the distance from the center of the selection in the center of each item, we don't need this method, other methods may use this information.

    now, your real question on Sin / Cos

    xn = Math.cos(Number(dx) * Math.PI / 180)+stepNum;

    Sin (angle) and cos (angle) expect angles in Radians, you not provide any angle in the formula above. We need calculate the angle between the selection and each path Center

            // get the angle formed between selection's center and current path's center
            var angle = get2pointAngle ([cx,cy], [px,py]);
    

    as soon as we have the angle we can apply to our variable 'Explosion', I guess is stepNum and get its x and is distance he needs to walk away selection

            // the distance to move is "stepNum" in the same direction as the angle found previously, get x and y vectors
            var dx = stepNum*Math.cos(angle);// distance x
            var dy = stepNum*Math.sin(angle);// distance y
    

    everything remains to be done is to move the paths, here is the whole thing

    // Explosion, AKA move all items away from selection
    // carlos canto
    // http://forums.adobe.com/thread/1382853?tstart=0
    
    var docID = app.activeDocument;
    var s0 = docID.selection[0];
    pID = docID.pathItems;
    
    var stepNum = 20; // this is the distance to "explode"
    
    // calculate Selection center position
    var cx = s0.position[0] + s0.width/2;
    var cy = s0.position[1] + s0.height/2;
    
    for (var i = 0; i < pID.length; i++) {
        var p = pID[i];
    
        // skip selected item
        if (!p.selected) {
            // calculate pathItem's center position
            var px = p.position[0] + p.width/2;
            var py = p.position[1] + p.height/2;
    
            // get the angle formed between selection's center and current path's center
            var angle = get2pointAngle ([cx,cy], [px,py]);
    
            // the distance to move is "stepNum" in the same direction as the angle found previously, get x and y vectors
            var dx = stepNum*Math.cos(angle);// distance x
            var dy = stepNum*Math.sin(angle);// distance y
    
            var moveMatrix = app.getTranslationMatrix(dx, dy);
            p.transform(moveMatrix);
            //stepNum+=stepNum;
        }
    }
    
    // return the angle from p1 to p2 in Radians. p1 is the origin, p2 rotates around p1
    function get2pointAngle(p1, p2) {
        var angl = Math.atan2(p2[1] - p1[1], p2[0] - p1[0]);
        if (angl<0) {   // atan2 returns angles from 0 to Pi, if angle is negative it means is over 180 deg or over Pi, add 360 deg or 2Pi, to get the absolute Positive angle from 0-360 deg
            angl = angl + 2*Math.PI;
        }
      return angl;
    }
    

Maybe you are looking for

  • Sierra of MacOS - iCloud Drive Documents &amp; Desktop keeps Getting Stuck download

    Hello as stated in the header after activating the iCloud Drive to include Documents and desktop download stuck guard. Since almost 2 weeks I started the task mean to ask iCloud to include above mentioned files. Total quantity was about 100 GB downlo

  • error message in the terminal window

    I created a new profile. And, in doing so, you work with a terminal window. During this process, I noticed this error message when I use FFI receive the error message in the terminal window and I can confirm that I see what you were using a new profi

  • 6 pro: Managment Services is offline (RNOS 6.4.2)

    All, I've seen this problem on other posts, but not of direct response. My NAS has stopped responding, both WebGUI and SSH work more. It could have happened after that she filled. Unfortunately no guarantee but any help is welcome. Dave

  • Not able to open sticky notes

    My reminder I tried to use my sticky notes on my laptop, but it keeps telling me that there was a problem at the opening of their, he said that if problems persist to consult for help... What can I do?

  • Lack of the favorite toolbar

    original title: tools Can't find the toolbar that has my favorites on it.