Exemplo n.º 1
0
void draw_vectors(t_hoa_meter *x, t_object *view, t_rect *rect)
{
	double x1, y1, size;
	t_matrix transform;
	t_elayer *g = ebox_start_layer((t_ebox *)x,  hoa_sym_vector_layer, rect->width, rect->height);
	
	if (g)
	{
		egraphics_matrix_init(&transform, 1, 0, 0, -1, rect->width / 2., rect->width / 2.);
		egraphics_set_matrix(g, &transform);
		size = 1. / 64. * rect->width;
    
        if(x->f_vector_type == hoa_sym_both || x->f_vector_type == hoa_sym_energy)
        {
            egraphics_set_color_rgba(g, &x->f_color_energy_vector);
            if(x->f_clockwise == hoa_sym_anticlock)
            {
                x1 = x->f_vector_coords[2] * x->f_radius_center * 0.85;
                y1 = x->f_vector_coords[3] * x->f_radius_center * 0.85;
            }
            else
            {
                double rad = radius(x->f_vector_coords[2], x->f_vector_coords[3]) * x->f_radius_center * 0.85;
                double ang = -azimuth(x->f_vector_coords[2], x->f_vector_coords[3]);
                x1 = abscissa(rad, ang);
                y1 = ordinate(rad, ang);
            }
            egraphics_arc(g, x1, y1, size, 0., HOA_2PI);
            egraphics_fill(g);
		}
        if(x->f_vector_type == hoa_sym_both || x->f_vector_type == hoa_sym_velocity)
        {
            egraphics_set_color_rgba(g, &x->f_color_velocity_vector);
            if(x->f_clockwise == hoa_sym_anticlock)
            {
                x1 = x->f_vector_coords[0] * x->f_radius_center * 0.85;
                y1 = x->f_vector_coords[1] * x->f_radius_center * 0.85;
            }
            else
            {
                double rad = radius(x->f_vector_coords[0], x->f_vector_coords[1]) * x->f_radius_center * 0.85;
                double ang = -azimuth(x->f_vector_coords[0], x->f_vector_coords[1]);
                x1 = abscissa(rad, ang);
                y1 = ordinate(rad, ang);
            }
            egraphics_arc(g, x1, y1, size, 0., HOA_2PI);
            egraphics_fill(g);
		}
        
		ebox_end_layer((t_ebox*)x,  hoa_sym_vector_layer);
	}
	ebox_paint_layer((t_ebox *)x, hoa_sym_vector_layer, 0., 0.);
}
Exemplo n.º 2
0
void hoa_map_3D_tilde_float(t_hoa_map_3D_tilde *x, float f)
{
    if(x->f_map->getNumberOfSources() == 1)
    {
		if(x->f_mode == 0)
		{
			if(eobj_getproxy((t_object *)x) == 1)
			{
				x->f_lines->setRadius(0, clip_min(f, 0.));
			}
			else if(eobj_getproxy((t_object *)x) == 2)
			{
				x->f_lines->setAzimuth(0, f);
			}
            else if(eobj_getproxy((t_object *)x) == 3)
			{
				x->f_lines->setElevation(0, f);
			}
		}
		else if(x->f_mode == 1)
		{
			if(eobj_getproxy((t_object *)x) == 1)
			{
                float abs = f;
                float ord = ordinate(x->f_lines->getRadius(0), x->f_lines->getAzimuth(0), x->f_lines->getElevation(0));
                float hei = height(x->f_lines->getRadius(0), x->f_lines->getAzimuth(0), x->f_lines->getElevation(0));
				x->f_lines->setRadius(0, radius(abs, ord, hei));
                x->f_lines->setAzimuth(0, azimuth(abs, ord, hei));
                x->f_lines->setElevation(0, elevation(abs, ord, hei));
			}
			else if(eobj_getproxy((t_object *)x) == 2)
			{
				float abs = abscissa(x->f_lines->getRadius(0), x->f_lines->getAzimuth(0), x->f_lines->getElevation(0));
                float ord = f;
                float hei = height(x->f_lines->getRadius(0), x->f_lines->getAzimuth(0), x->f_lines->getElevation(0));
				x->f_lines->setRadius(0, radius(abs, ord, hei));
                x->f_lines->setAzimuth(0, azimuth(abs, ord, hei));
                x->f_lines->setElevation(0, elevation(abs, ord, hei));
			}
            else if(eobj_getproxy((t_object *)x) == 3)
			{
				float abs = abscissa(x->f_lines->getRadius(0), x->f_lines->getAzimuth(0), x->f_lines->getElevation(0));
                float ord = ordinate(x->f_lines->getRadius(0), x->f_lines->getAzimuth(0), x->f_lines->getElevation(0));
                float hei = f;
                x->f_lines->setRadius(0, radius(abs, ord, hei));
                x->f_lines->setAzimuth(0, azimuth(abs, ord, hei));
                x->f_lines->setElevation(0, elevation(abs, ord, hei));
			}
		}
    }
}
Exemplo n.º 3
0
// Depends on item parameters, but not latent distribution
void ba81NormalQuad::cacheOutcomeProb(double *param, bool wantLog)
{
	for (size_t lx=0; lx < layers.size(); ++lx) {
		layer &l1 = layers[lx];
		l1.outcomeProbX.resize(ig.totalOutcomes * l1.totalQuadPoints);
	}

#pragma omp parallel for num_threads(ig.numThreads)
	for (int ix=0; ix < ig.numItems(); ix++) {
		const double *ispec = ig.spec[ix];
		int id = ispec[RPF_ISpecID];
		double *iparam = param + ig.paramRows * ix;
		rpf_prob_t prob_fn = wantLog? Glibrpf_model[id].logprob : Glibrpf_model[id].prob;

		Eigen::VectorXi abx(abscissaDim());
		Eigen::VectorXd abscissa(abscissaDim());

		for (size_t lx=0; lx < layers.size(); ++lx) {
			layer &l1 = layers[lx];
			l1.cacheOutcomeProb(ispec, iparam, prob_fn, ix, abx, abscissa);
		}
	}
	// for (size_t lx=0; lx < layers.size(); ++lx) {
	// 	layer &l1 = layers[lx];
	// 	mxPrintMat("op", l1.outcomeProbX);
	// }
}
Exemplo n.º 4
0
void hoa_map_float(t_hoa_map *x, double f)
{
    if(x->f_map->getNumberOfSources() == 1)
    {
		if(x->f_mode == hoa_sym_polar)
		{
			if(proxy_getinlet((t_object *)x) == 1)
			{
				x->f_lines->setRadius(0, clip_min(f, 0.));
			}
			else if(proxy_getinlet((t_object *)x) == 2)
			{
				x->f_lines->setAzimuth(0, f);
			}
		}
		else if(x->f_mode == hoa_sym_cartesian)
		{
			if(proxy_getinlet((t_object *)x) == 1)
			{
                float ord = ordinate(x->f_lines->getRadius(0), x->f_lines->getAzimuth(0));
				x->f_lines->setRadius(0, radius(f, ord));
                x->f_lines->setAzimuth(0, azimuth(f, ord));
			}
			else if(proxy_getinlet((t_object *)x) == 2)
			{
				float abs = abscissa(x->f_lines->getRadius(0), x->f_lines->getAzimuth(0));
                x->f_lines->setRadius(0, radius(abs, f));
				x->f_lines->setAzimuth(0, azimuth(abs, f));
			}
		}
    }
}
Exemplo n.º 5
0
	void Vector::setChannelsAzimuth(double* azimuths)
    {
        Planewaves::setChannelsAzimuth(azimuths);
		for (int i = 0; i < m_number_of_channels; i++)
		{
			m_channels_abscissa_float[i] = m_channels_abscissa_double[i] = abscissa(1., m_channels_azimuth[i] + m_offset);
			m_channels_ordinate_float[i] = m_channels_ordinate_double[i] = ordinate(1., m_channels_azimuth[i] + m_offset);
		}
    }
Exemplo n.º 6
0
    void Vector::setChannelsOffset(double offset)
    {
        m_offset = wrap_twopi(offset);
        for (int i = 0; i < m_number_of_channels; i++)
		{
			m_channels_abscissa_float[i] = m_channels_abscissa_double[i] = abscissa(1., m_channels_azimuth[i] + m_offset);
			m_channels_ordinate_float[i] = m_channels_ordinate_double[i] = ordinate(1., m_channels_azimuth[i] + m_offset);
		}
    }
Exemplo n.º 7
0
void draw_harmonics(t_hoa_scope_3D *x, t_object *view, t_rect *rect)
{
    t_matrix transform;
	t_elayer *g = ebox_start_layer((t_ebox *)x, hoa_sym_harmonics_layer, rect->width, rect->height);
    
	if (g)
	{
        double value;
        egraphics_rotate(g, HOA_PI);
		egraphics_set_line_width(g, 1);
        egraphics_matrix_init(&transform, 1, 0, 0, -1, x->f_center, x->f_center);
        egraphics_set_matrix(g, &transform);
        
        float increment = 2;
        float ratio = x->f_radius / (x->f_scope->getNumberOfRows() * 0.5);
        for(int j = x->f_scope->getNumberOfRows() * 0.5; j < x->f_scope->getNumberOfRows(); j++)
        {
            for(int i = 0; i < x->f_scope->getNumberOfColumns(); )
            {
                value = x->f_scope->getValue(j, i);
                if(value > 0)
                    egraphics_set_color_rgba(g, &x->f_color_ph);
                else
                    egraphics_set_color_rgba(g, &x->f_color_nh);
                float azym = (double)i / (double)x->f_scope->getNumberOfColumns() * HOA_2PI;
                float elev = (double)j / (double)x->f_scope->getNumberOfRows() * HOA_PI;
                float abs = abscissa(x->f_radius, azym, elev);
                float ord = ordinate(x->f_radius, azym, elev);
                /*
                azym = (double)(i + 1) / (double)x->f_scope->getNumberOfColumns() * HOA_2PI;
                elev = (double)(j + 1) / (double)x->f_scope->getNumberOfRows() * HOA_PI;
                float abs2 = abscissa(x->f_radius, azym, elev);
                float ord2 = ordinate(x->f_radius, azym, elev);
                 */
                egraphics_circle(g, abs, ord, cos((j - x->f_scope->getNumberOfRows()) / (x->f_scope->getNumberOfRows() * HOA_PI)) * ratio);
                egraphics_fill(g);
                i += increment;
            }
            /*
            if(increment < x->f_scope->getNumberOfRows() * 0.5 - 1)
                increment *= 1.05;
             */
        }
                 
		ebox_end_layer((t_ebox *)x, hoa_sym_harmonics_layer);
	}
	ebox_paint_layer((t_ebox *)x, hoa_sym_harmonics_layer, 0., 0.);
}
Exemplo n.º 8
0
 void Vector::setChannelAzimuth(unsigned int index, double azimuth)
 {
     Planewaves::setChannelAzimuth(index, azimuth);
     m_channels_abscissa_float[index] = m_channels_abscissa_double[index] = abscissa(1., m_channels_azimuth[index] + m_offset);
     m_channels_ordinate_float[index] = m_channels_ordinate_double[index] = ordinate(1., m_channels_azimuth[index] + m_offset);
 }