carrot-ar/carrot

Fix calculation of E_P to handle 3+ devices

mccoykillian opened this issue · 0 comments

Currently, E_P calculations are only supported for two devices. In order to send responses to more than two devices, distinct calculations must be sent upon individual recipient broadcast. Therefore this issue cannot be completed until issue #66 is addressed.

When broadcasting distinct responses to each recipient becomes possible, the below psuedocode should make sure that the correct event placement is being broadcast to each type of device registered with the server:

when building response messages:

	event //unconverted event coordinates that may be recalculated twice depending on a particular broadcast's sender and recipient's roles
	var e_l //obtain event in primary device's coordinates (first potential calcuation)
	var e_p //obtain event in secondary device's coordinates (second potential calcuation)

	if sender is a secondary device  {  //establish primary perspective

		//calculate object in primary device's coordinates
			find primary device
			e_l = getE_L(sender, primaryDevice, event)

	} else { //sender is primary device & already in perspective
		e_l = event
	}

	//transform and/or broadcast primary device's event 
	for the list of recipient devices
		if recipient != primaryDevice && sender != recipient {
			e_p = getE_P(recipient, e_l)
			//calculate e_p from primary to secondary device
				//e_p = e_l - o_p
					//where o_p = t_p - t_l
		} else { //device == primary device || self to self broadcast
			e_p = e_l
		}
		broadcast e_p as the offset in the response for this recipient device

The existing getE_P function will probably need to be separated into getE_L (get event coordinates local to the primary device) and getE_P (get event coordinates relative to the target device) for the two different stages of calculations as seen above. The beginning work of this can be found in the handle3PlusDevices branch.