[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-edu-devel
Subject:    [kde-edu]: patch for linearmotor
From:       "Aditya C.S" <aditya.gnu () gmail ! com>
Date:       2010-06-07 19:26:14
Message-ID: AANLkTilL3LqS4hj1_ln6pY0RU-t3TqOmFo8PiBM26NCg () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


Hi,
    Anlge made by the applied force is shown in this

[Attachment #5 (text/html)]

Hi,<br>=A0=A0=A0 Anlge made by the applied force is shown in this<br>

--001636e0a4ab7906340488757a57--
["angle.patch" (text/x-patch)]

Index: motor.h
===================================================================
--- motor.h	(revision 1130215)
+++ motor.h	(working copy)
@@ -54,6 +54,9 @@
     /** Set pointer to the connected body */
     void setBody(Object* body);
 
+   /** Get angle of the body */
+    double angle() const; 
+   
     /** Local position of the motor on the body
      *  or in the world (if the motor is not connected) */
     const Vector2d& localPosition() const { return _localPosition; }
@@ -79,6 +82,7 @@
 
     Particle*  _p;
     RigidBody* _r;
+    double _angle;
 };
 
 /** \ingroup forces
Index: motor.cc
===================================================================
--- motor.cc	(revision 1130215)
+++ motor.cc	(working copy)
@@ -28,6 +28,7 @@
 STEPCORE_META_OBJECT(LinearMotor, QT_TRANSLATE_NOOP("ObjectClass", "LinearMotor"), \
QT_TR_NOOP("Linear motor: applies a constant force to a given position of the body"), \
0,  STEPCORE_SUPER_CLASS(Item) STEPCORE_SUPER_CLASS(Force),
     STEPCORE_PROPERTY_RW(Object*, body, QT_TRANSLATE_NOOP("PropertyName", "body"), \
STEPCORE_UNITS_NULL, QT_TR_NOOP("Body"), body, setBody) +    \
STEPCORE_PROPERTY_R_D(double, angle, QT_TRANSLATE_NOOP("PropertyName", "angle"), \
QT_TRANSLATE_NOOP("Units", "deg"), QT_TR_NOOP("angle"), angle)  \
STEPCORE_PROPERTY_RW(StepCore::Vector2d, localPosition, \
QT_TRANSLATE_NOOP("PropertyName", "localPosition"), QT_TRANSLATE_NOOP("Units", "m"), \
QT_TR_NOOP("Position of the motor on a body"), localPosition, setLocalPosition)  \
STEPCORE_PROPERTY_RW(StepCore::Vector2d, forceValue, \
QT_TRANSLATE_NOOP("PropertyName", "forceValue"), QT_TRANSLATE_NOOP("Units", "N"), \
QT_TR_NOOP("Value of the force, acting on the body"), forceValue, setForceValue))  
@@ -45,6 +46,14 @@
     setColor(0xff0000ff);
 }
 
+double LinearMotor::angle() const
+{
+  #define PI 3.14159265358979323846
+
+  double angle = atan(_forceValue[1]/_forceValue[0]);
+  return angle*180/PI;
+}
+
 void LinearMotor::calcForce(bool calcVariances)
 {
      if(_p) _p->applyForce(_forceValue);



_______________________________________________
kde-edu mailing list
kde-edu@mail.kde.org
https://mail.kde.org/mailman/listinfo/kde-edu


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic