Ejemplo n.º 1
0
const Vector Vector::operator+(const Vector &rhs) const
{
	Vector ret(0,0,0);
	ret.setX(getX() + rhs.getX());
	ret.setY(getY() + rhs.getY());
	ret.setZ(getZ() + rhs.getZ());
	
	return ret;
}
Ejemplo n.º 2
0
const Vector Vector::operator/(const double &rhs) const
{
	Vector ret(0,0,0);
	ret.setX(getX() / rhs);
	ret.setY(getY() / rhs);
	ret.setZ(getZ() / rhs);
	
	return ret;
}
Ejemplo n.º 3
0
bool CGLVector3D::isEqualTo(CGLVector3D const& b) const
{
	bool retour = false;
	if (getX()==b.getX())
		if (getY()==b.getY())
			if (getZ()==b.getZ())
				retour = true;
	return retour;
}
Ejemplo n.º 4
0
//custom - operator for the vector class
Vector Vector::operator -(Vector &p)
{
	Vector outV;
	outV.setX(getX() - p.getX());
	outV.setY(getY() - p.getY());
	outV.setZ(getZ() - p.getZ());

	return outV;
}
Ejemplo n.º 5
0
Vector* Vertex::subtract(Vertex* vertex)
{
   Vector* vector = new Vector(0, 0, 0);

   vector->setX(getX() - vertex->getX());
   vector->setY(getY() - vertex->getY());
   vector->setZ(getZ() - vertex->getZ());

   return vector;
}
bool State::operator==(const State& s2) const
{
  return (fabs(getX() - s2.getX()) < FLOAT_CMP_THR &&
          fabs(getY() - s2.getY()) < FLOAT_CMP_THR &&
          fabs(getZ() - s2.getZ()) < FLOAT_CMP_THR &&
          fabs(angles::shortest_angular_distance(ivRoll, s2.ivRoll)) < FLOAT_CMP_THR &&
          fabs(angles::shortest_angular_distance(ivPitch, s2.ivPitch)) < FLOAT_CMP_THR &&
          fabs(angles::shortest_angular_distance(ivYaw, s2.ivYaw)) < FLOAT_CMP_THR &&
          ivLeg == s2.getLeg());
}
Ejemplo n.º 7
0
Vector3 HomogenusPosition::normalizeToVector3() const
{
	Vector3 result;
	
	result.setX(getX()/getW());
	result.setY(getY()/getW());
	result.setZ(getZ()/getW());
	
	return result;
}
Ejemplo n.º 8
0
string Layer::SVGpath(const Vector2d &trans) const
{
  ostringstream ostr;
  ostr << "\t<g id=\"Layer_"<< LayerNo
       << "_z:" << getZ() << "\">" << endl;
  for (uint i = 0; i<polygons.size(); i++) {
    ostr << polygons[i].SVGpath(trans) << endl;
  }
  ostr << "\t</g>";
  return ostr.str();
}
Ejemplo n.º 9
0
 void EditorTile::show()
 {
     if (!S(Game)->getInterface()->isMouseOver())
     {
         EditorMap* map = (EditorMap*) S(Game)->getMap();
         if (map->usingBrush())
         {
             float d = getBrushEffect();
             if (d > 0 && d <= 1)
                 showColored(engine::graphics::Color((1 - d) * 127 + 128, (1 - d) * 127 + 128, (1 - d) * 127 + 128));
             
             else
                 Tile::show();
         }
         else if (map->puttingBuilding())
         {
             engine::Vector2d pointerPosition = map->getPointerPosition();
             int x = pointerPosition.getRoundX();
             int y = pointerPosition.getRoundY();
             entity::BuildingModel* buildingModel = map->getBuildingModel();
             if (x - buildingModel->getSize() < (int)m_x && (int)m_x <= x && y - buildingModel->getSize() < (int)m_y && (int)m_y <= y)
             {
                 if (buildingModel->canBeBuilt(map, x, y))
                 {
                     showColored(engine::graphics::Color(128, 128, 128));
                 }
                 else
                 {
                     Tile* tile = map->getTile(x, y);
                     if (!isAccessible() || (tile != NULL && tile->getZ() != getZ()))
                         showColored(engine::graphics::Color(255, 0, 0));
                         
                     else
                         showColored(engine::graphics::Color(128, 128, 128));
                 }
             }
             else
                 Tile::show();
         }
         else if (map->puttingUnit())
         {
             m_color->use();
             
             MapObject::show();
             
             if (m_doodad != NULL)
                 m_doodad->show();
         }
         else
             Tile::show();
     }
     else
         Tile::show();
 }
Ejemplo n.º 10
0
double Point::distanceTo(const Point &a) const {
    double x1, x2, y1, y2, z1, z2;
    x2 = a.getX();
    x1 = getX();
    y2 = a.getY();
    y1 = getY();
    z2 = a.getZ();
    z1 = getZ();

    return sqrt(pow((x2-x1), 2.0)+pow((y2-y1), 2.0)+pow((z2-z1), 2.0));
}
Ejemplo n.º 11
0
BITMAP * Objets::getProprietes(int p_x,int p_y, int p_w, int p_h) {
    clear_to_color(proprietes,makecol(255,255,255));
    rect(proprietes,1,1,149,199,0);
    textprintf_ex(proprietes, font,35,10, makecol(0, 0, 0),makecol(255, 255, 255), "Proprietes");
    line(proprietes,0,20,200,20,0);
    textprintf_ex(proprietes, font,10,30, makecol(0, 0, 0),makecol(255, 255, 255), "Type : %s",nom);
    int _x,_y,_z;
    _x=(getX()-p_x);
    _y=(getY()-p_y);
    _z=getZ();

    if (!Tx->getSaisie())
        Tx->setValeur(_x);
    if (!Ty->getSaisie())
        Ty->setValeur(_y);
    if (!Tz->getSaisie())
        Tz->setValeur(_z);
    if (!Tw->getSaisie())
        Tw->setValeur(getW());
    if (!Th->getSaisie())
        Th->setValeur(getH());
    if (!Td->getSaisie())
        Td->setValeur(getD());

    textprintf_ex(proprietes, font,10,45, makecol(0, 0, 0),makecol(255, 255, 255), "x =");
    blit(Tx->getImage(),proprietes,0,0,Tx->getX(),Tx->getY(),Tx->getW(),Tx->getH());
    textprintf_ex(proprietes, font,10,60, makecol(0, 0, 0),makecol(255, 255, 255), "y =");
    blit(Ty->getImage(),proprietes,0,0,Ty->getX(),Ty->getY(),Ty->getW(),Ty->getH());
    textprintf_ex(proprietes, font,10,75, makecol(0, 0, 0),makecol(255, 255, 255), "z =");
    blit(Tz->getImage(),proprietes,0,0,Tz->getX(),Tz->getY(),Tz->getW(),Tz->getH());
    textprintf_ex(proprietes, font,10,90, makecol(0, 0, 0),makecol(255, 255, 255), "Longueur =");
    blit(Tw->getImage(),proprietes,0,0,Tw->getX(),Tw->getY(),Tw->getW(),Tw->getH());
    textprintf_ex(proprietes, font,10,105, makecol(0, 0, 0),makecol(255, 255, 255), "Largeur =");
    blit(Th->getImage(),proprietes,0,0,Th->getX(),Th->getY(),Th->getW(),Th->getH());
    textprintf_ex(proprietes, font,10,120, makecol(0, 0, 0),makecol(255, 255, 255), "Hauteur =");
    blit(Td->getImage(),proprietes,0,0,Td->getX(),Td->getY(),Td->getW(),Td->getH());

    char *lesens;
    if (sens=="N")
        lesens="Nord";
    else if (sens=="E")
        lesens="Est";
    else if (sens=="S")
        lesens="Sud";
    else if (sens=="O")
        lesens="Ouest";
    textprintf_ex(proprietes, font,10,135, makecol(0, 0, 0),makecol(255, 255, 255), "Sens = %s",lesens);
    delete [] lesens;

    textprintf_ex(proprietes, font,10,150, makecol(0, 0, 0),makecol(255, 255, 255), "Couleur = ");
    rectfill(proprietes,90,148,100,158,q_c);
    rect(proprietes,90,148,100,158,0);
    return proprietes;
}
Ejemplo n.º 12
0
float * Frog::getPos() {
   if (animateComplete) {
      init();
      pos[0] = 0;
      pos[1] = 0;
      pos[2] = getZ();
      return pos;
   } else {
      return NULL;
   }
}
Ejemplo n.º 13
0
void ZDvidTile::printInfo() const
{
  std::cout << "Dvid tile: " << std::endl;
  m_res.print();
  std::cout << "Offset: " << getX() << ", " << getY() << ", " << getZ() << std::endl;
  if (m_image != NULL) {
    std::cout << "Size: " << m_image->width() << " x " << m_image->height()
              << std::endl;
  }

}
Ejemplo n.º 14
0
void OGRLinearRing::closeRings()

{
    if( nPointCount < 2 )
        return;

    if( getX(0) != getX(nPointCount-1) 
        || getY(0) != getY(nPointCount-1)
        || getZ(0) != getZ(nPointCount-1) )
    {
        /* Avoid implicit change of coordinate dimensionality
         * if z=0.0 and dim=2
         */
        if( getCoordinateDimension() == 2 )
            addPoint( getX(0), getY(0) );
        else
            addPoint( getX(0), getY(0), getZ(0) );
            
    }
}
Ejemplo n.º 15
0
void SceneComponent::serialize(Serializer& serializer)
{
	Component::serialize(serializer);

	serializer.save("visible", isVisible());
	serializer.save("parent", getParentId());
	serializer.save("pos", getPosition());
	serializer.save("rot", getRotation());
	serializer.save("sca", getScale());
	serializer.save("z", getZ());
}
Ejemplo n.º 16
0
bool ZIntPoint::operator < (const ZIntPoint &pt) const
{
  if (getZ() < pt.getZ()) {
    return true;
  } else if (getZ() > pt.getZ()) {
    return false;
  } else {
    if (getY() < pt.getY()) {
      return true;
    } else if (getY() > pt.getY()) {
      return false;
    } else {
      if (getX() < pt.getX()) {
        return true;
      }
    }
  }

  return false;
}
Ejemplo n.º 17
0
void SFVec3f::getValue(jobject field, int bConstField) {
	assert(field);
	JNIEnv		*jniEnv			= getJniEnv();
	jclass		classid			= bConstField ? getConstFieldID() : getFieldID();
	jmethodID	setValueMethod	= bConstField ? getConstSetValueMethodID() : getSetValueMethodID();
	assert(classid && setValueMethod);
	jfloat		x				= getX();
	jfloat		y				= getY();
	jfloat		z				= getZ();
	jniEnv->CallVoidMethod(field, setValueMethod, x, y, z);
}
/**
  * Recalculate roll and pitch values for the current sample.
  *
  * @note We only do this at most once per sample, as the necessary trigonemteric functions are rather
  *       heavyweight for a CPU without a floating point unit.
  */
void MicroBitAccelerometer::recalculatePitchRoll()
{
    double x = (double) getX(NORTH_EAST_DOWN);
    double y = (double) getY(NORTH_EAST_DOWN);
    double z = (double) getZ(NORTH_EAST_DOWN);

    roll = atan2(y, z);
    pitch = atan(-x / (y*sin(roll) + z*cos(roll)));

    status |= MICROBIT_ACCEL_PITCH_ROLL_VALID;
}
Ejemplo n.º 19
0
double NeuroNode::calculateLength( const CylBase& parent )
{
	if ( &parent == this ) // Do nothing
			return getLength();
	double dx = parent.getX() - getX();
	double dy = parent.getY() - getY();
	double dz = parent.getZ() - getZ();
	double ret = sqrt( dx * dx + dy * dy + dz * dz );
	setLength( ret );
	return ret;
}
void Adafruit_ADXL345_Unified::getEvent(sensors_event_t *event) {
    /* Clear the event */
    memset(event, 0, sizeof(sensors_event_t));

    event->version   = sizeof(sensors_event_t);
    event->sensor_id = _sensorID;
    event->type      = SENSOR_TYPE_ACCELEROMETER;
    event->timestamp = 0;
    event->acceleration.x = getX() * ADXL345_MG2G_MULTIPLIER * SENSORS_GRAVITY_STANDARD;
    event->acceleration.y = getY() * ADXL345_MG2G_MULTIPLIER * SENSORS_GRAVITY_STANDARD;
    event->acceleration.z = getZ() * ADXL345_MG2G_MULTIPLIER * SENSORS_GRAVITY_STANDARD;
}
Ejemplo n.º 21
0
void calculateView()
{
    cameraPos.z = getZ( cameraPos.x, cameraPos.y ) + tripodHeight;
    
    vec4 lookAtPos( cameraPos.x + cos( cameraRotZ ) * cos( cameraRotXY ),
                    cameraPos.y + cos( cameraRotZ ) * sin( cameraRotXY ),
                    cameraPos.z + sin( cameraRotZ ),
                    1.0 );

    projStack.push( Perspective( 45.0, 1.0, 0.01, viewLimitOn ? viewLimit : 3.0 * std::fmax( gridSize, tripodHeight ) ) );
    mvStack.push( LookAt( cameraPos, lookAtPos, up ) );
}
Ejemplo n.º 22
0
//===========================================
// TextEntity::updateModel
//===========================================
void TextEntity::updateModel() const {
   float32_t x = getTranslation_abs().x;
   float32_t y = getTranslation_abs().y;
   float32_t z = getZ();

   float32_t texSectionX1 = m_font->getTextureSection().getPosition().x;
   float32_t texSectionY1 = m_font->getTextureSection().getPosition().y;
   float32_t texSectionX2 = texSectionX1 + m_font->getTextureSection().getSize().x;
   float32_t texSectionY2 = texSectionY1 + m_font->getTextureSection().getSize().y;

   float32_t texW = static_cast<float32_t>(m_font->getTexture()->getWidth());
   float32_t texH = static_cast<float32_t>(m_font->getTexture()->getHeight());

   float32_t pxChW = static_cast<float32_t>(m_font->getCharWidth());    // Char dimensions in pixels
   float32_t pxChH = static_cast<float32_t>(m_font->getCharHeight());

   int rowLen = static_cast<int>(static_cast<float32_t>(texSectionX2 - texSectionX1) / static_cast<float32_t>(pxChW));

   StackAllocator::marker_t marker = gGetMemStack().getMarker();
   vvvtt_t* verts = reinterpret_cast<vvvtt_t*>(gGetMemStack().alloc(m_text.size() * 6 * sizeof(vvvtt_t)));

   int v = 0;
   for (uint_t i = 0; i < m_text.length(); ++i) {
      // Character world coords (pre-transformation)
      float32_t chX = x + static_cast<float32_t>(i) * m_size.x;
      float32_t chY = y;

      float32_t srcX = texSectionX1 + pxChW * static_cast<float32_t>((m_text[i] - ' ') % rowLen);
      float32_t srcY = texSectionY2 - pxChH * static_cast<float32_t>((m_text[i] - ' ') / rowLen + 1);

      float32_t tY1 = srcY / texH;
      float32_t tY2 = (srcY + pxChH) / texH;
      tY1 = 1.f - tY1;
      tY2 = 1.f - tY2;

      verts[v] = vvvtt_t(chX + m_size.x, chY,            z,    (srcX + pxChW) / texW, tY1);    ++v;
      verts[v] = vvvtt_t(chX + m_size.x, chY + m_size.y, z,    (srcX + pxChW) / texW, tY2);    ++v;
      verts[v] = vvvtt_t(chX,            chY,            z,    srcX / texW,           tY1);    ++v;
      verts[v] = vvvtt_t(chX + m_size.x, chY + m_size.y, z,    (srcX + pxChW) / texW, tY2);    ++v;
      verts[v] = vvvtt_t(chX,            chY + m_size.y, z,    srcX / texW,           tY2);    ++v;
      verts[v] = vvvtt_t(chX,            chY,            z,    srcX / texW,           tY1);    ++v;
   }

   m_model.eraseVertices();
   m_model.setVertices(0, verts, 6 * m_text.size());
   m_model.setColour(getFillColour());
   m_model.setLineWidth(0);
   m_model.setTextureHandle(m_font->getTexture()->getHandle());

   m_renderer.bufferModel(&m_model);

   gGetMemStack().freeToMarker(marker);
}
Ejemplo n.º 23
0
//gets the x,y,z coordinates from the off file
int get_tuples(FILE *fp, jmesh *jm){
    int status, line=0;
    for(int i=0; i < jm->nvert; i++){
        status=fscanf(fp, "%f %f %f", getX(jm, i), getY(jm, i), getZ(jm, i)); 
        line++;
        if(status != 3){
            return line;
        }
        skip_line(fp);
    }
    return line;
}
Ejemplo n.º 24
0
    void testDoubleDerived() {
      DoubleDerivedVTBL d;
      d.x = 1;
      d.y = 2;
      d.z = 3;
      clang_analyzer_eval(getX(d) == 1); // expected-warning{{TRUE}}
      clang_analyzer_eval(getY(d) == 2); // expected-warning{{TRUE}}
      clang_analyzer_eval(getZ(d) == 3); // expected-warning{{TRUE}}

      Base b(d);
      clang_analyzer_eval(getX(b) == 1); // expected-warning{{TRUE}}

      DerivedVTBL d2(d);
      clang_analyzer_eval(getX(d2) == 1); // expected-warning{{TRUE}}
      clang_analyzer_eval(getY(d2) == 2); // expected-warning{{TRUE}}

      DoubleDerivedVTBL d3(d);
      clang_analyzer_eval(getX(d3) == 1); // expected-warning{{TRUE}}
      clang_analyzer_eval(getY(d3) == 2); // expected-warning{{TRUE}}
      clang_analyzer_eval(getZ(d3) == 3); // expected-warning{{TRUE}}
    }
Ejemplo n.º 25
0
float ColorSpace::getH()
{
    float h;
    if (getC() == 0.0f)
    {
        return 0.5f;
    }
    if (red == getZ())
    {
        h = ((float)(grn - blue) / getC() + 6.0f);
        while (h > 6.0f)
        {
            h = h - 6.0f;
        }
    } else if (grn == getZ())
    {
        h = (blue - red) / getC() + 2.0f;
    } else {
        h = (red - grn) / getC() + 4.0f;
    }
    return h / 6.0f;
}
Ejemplo n.º 26
0
TRIGGER( use )(obj user)
{
  int Q5CE = getX(getLocation(this)) + 0x01;
  int Q4FT = getY(getLocation(this));
  int Q4FU = getZ(getLocation(this));
  loc Q64L = loc( Q5CE, Q4FT, Q4FU );
  if(!hasObjVar(this, "not_trapped"))
  {
    doLocAnimation(Q64L, 0x372A, 0x02, 0x14, 0x00, 0x00);
    return(0x00);
  }
  return(0x01);
}
Ejemplo n.º 27
0
void ball::collide(ball* with) {
	float xdelta = with->getX() - getX();
	float ydelta = with->getY() - getY();
	float zdelta = with->getZ() - getZ();

	xvel = (xvel + xdelta) * bouncy;
	yvel = (yvel + ydelta) * bouncy;
	zvel = (zvel + zdelta) * bouncy;
	with->xvel = (with->xvel + -xdelta) * with->bouncy;
	with->yvel = (with->yvel + -ydelta) * with->bouncy;
	with->zvel = (with->zvel + -zdelta) * with->bouncy;
	complete = false;
}
Ejemplo n.º 28
0
Car::Car(int line, GameMap::Linetype linetype)
:CarLikeObject(line, linetype, CARWIDTH, CARHEIGHT, "CAR") {
	setDisY((double)SPEED/2);
	std::vector<std::string> namelist = { "police_car", "Taxi", "truck_blue" };
	int ind = rand() % 3;
	if (ind == 0) setColor(23, 23, 145);
	else if (ind == 1) setColor(145, 145, 23);
	else setColor(77, 77, 145);
	
	vec3 pos_glo = assetManager->getGlobalPos(namelist[ind]);
	setPos(getX() + pos_glo.x, getY() + pos_glo.y, getZ() + pos_glo.z);
	setModel(assetManager->getModel(namelist[ind]));
}
Ejemplo n.º 29
0
void ShapeContainer::update() {
    setX(getX()+getSpeedX());
    if (getX() > 10.00f) setSpeed(getSpeedX()*-1);
    if (getX() < -10.00f) setSpeed(getSpeedX()*-1);
    setY(getY()+getSpeedY());
    setZ(getZ()+getSpeedZ());
    setRotateValues(getRotateValueX()+getRotateSpeedValueX(), getRotateValueY()+getRotateSpeedValueY(), getRotateValueZ()+getRotateSpeedValueZ());


    for(std::list<Shape*>::iterator i=shapeList.begin(); i != shapeList.end(); ++i) {
        (*i)->update();
    }
}
Ejemplo n.º 30
0
void ShapeContainer::draw() {
    glPushMatrix();
    glTranslatef(getX(), getY(), getZ());
    glRotatef(getRotateValueZ(), 0.00, 0.00, 1.00);
    glRotatef(getRotateValueY(), 0.00f, 1.00f, 0.00f);
    glRotatef(getRotateValueX(),1.00f, 0.00, 0.00);

    for(std::list<Shape*>::iterator i=shapeList.begin(); i != shapeList.end(); ++i) {
        (*i)->draw();
    }

    glPopMatrix();
}