Vertical Vertical::vs_los_recovery(const Vect3& s, const Vect3& vo, const Vect3& vi, const double H, const double t, int epsv) { if (t <= 0) return NoVerticalSolution; Vect3 v = vo-vi; double nvz = (epsv*H - s.z)/t; if (s.z*v.z >= 0 && std::abs(v.z) >= std::abs(nvz)) return Vertical(vo.z); else return Vertical(nvz+vi.z); }
/* Solve the following equation on vz: * sz+t*vz = eps*H, * * where t = Theta_D(s,v,epsp). * eps determines the bottom, i.e.,-1, or top, i.e., 1, circle. */ Vertical Vertical::vs_circle(const Vect3& s, const Vect3& vo, const Vect3& vi, const int eps, const double D, const double H) { Vect2 s2 = s.vect2(); Vect2 vo2 = vo.vect2(); Vect2 vi2 = vi.vect2(); Vect2 v2 = vo2-vi2; if (vo2.almostEquals(vi2) && eps == sign(s.z)) return Vertical(vi.z); else if (Horizontal::Delta(s2,v2,D) > 0) return vs_only(s,v2,Horizontal::Theta_D(s2,v2,larcfm::Exit,D),eps,D,H).add_this(vi.z); return NoVerticalSolution; }
void TBarView::SaveSettings() { desk_settings *settings = ((TBarApp *)be_app)->Settings(); settings->vertical = Vertical(); settings->left = Left(); settings->top = Top(); settings->ampmMode = MilTime(); settings->state = (uint32)State(); settings->width = 0; settings->showTime = ShowingClock(); fReplicantTray->RememberClockSettings(); settings->alwaysOnTop = (Window()->Feel() & B_FLOATING_ALL_WINDOW_FEEL) != 0; }
//Calls the calculation functions, and compares them for the largest. unsigned long long Largest(std::vector<std::vector<int>> grid ){ int gwidth = grid[0].size(); int glength = grid.size(); unsigned long long largest = 0; for(int a = 0; a < gwidth; ++a){ for(int b = 0; b < glength; ++b){ largest = std::max(largest,Horizontal(a,b,grid)); largest = std::max(largest,Vertical(a,b,grid)); largest = std::max(largest,ForDiag(a,b,grid)); largest = std::max(largest,BackDiag(a,b,grid)); } } return largest; }
void TBarView::PlaceTray(bool, bool, BRect screenFrame) { BPoint statusLoc; if (fState == kFullState) { fDragRegion->ResizeTo(fBarMenuBar->Frame().Width(), kMenuBarHeight); statusLoc.y = fBarMenuBar->Frame().bottom + 1; statusLoc.x = 0; fDragRegion->MoveTo(statusLoc); if (!fReplicantTray->IsHidden()) fReplicantTray->Hide(); return; } if (fReplicantTray->IsHidden()) fReplicantTray->Show(); if (fTrayLocation != 0) { fReplicantTray->SetMultiRow(fVertical); fReplicantTray->RealignReplicants(); fDragRegion->ResizeToPreferred(); if (fVertical) { #if SA_CLOCK if (fShowClock) statusLoc.y = fClock->Frame().bottom + 1; else #endif statusLoc.y = fBarMenuBar->Frame().bottom + 1; statusLoc.x = 0; if (Left() && Vertical()) fReplicantTray->MoveTo(5, 2); else fReplicantTray->MoveTo(2, 2); } else { statusLoc.x = screenFrame.Width() - fDragRegion->Bounds().Width(); statusLoc.y = -1; } fDragRegion->MoveTo(statusLoc); } }
void TwoAxisValuatorModule::ModuleProcessSlider(InputManager::VirtualInputId SliderId, double MovedAmount) { if (IsButtonPressed(0)) { if (0 != m_Slide.GetSelectedObjectId()) { Wm5::Vector3d ToObject = m_Slide.GetSelectedObject().GetPosition() - Wm5::Vector3d(camera.x, camera.y, camera.z); ToObject.Normalize(); Wm5::Vector3d Horizontal(Wm5::Vector3d::ZERO), Vertical(Wm5::Vector3d::ZERO); Horizontal.X() += Wm5::Mathd::Cos(camera.rh * Wm5::Mathd::DEG_TO_RAD); Horizontal.Y() += -Wm5::Mathd::Sin(camera.rh * Wm5::Mathd::DEG_TO_RAD); Vertical.X() += Wm5::Mathd::Sin(camera.rh * Wm5::Mathd::DEG_TO_RAD) * Wm5::Mathd::Sin(camera.rv * Wm5::Mathd::DEG_TO_RAD); Vertical.Y() += Wm5::Mathd::Cos(camera.rh * Wm5::Mathd::DEG_TO_RAD) * Wm5::Mathd::Sin(camera.rv * Wm5::Mathd::DEG_TO_RAD); Vertical.Z() += -Wm5::Mathd::Cos(camera.rv * Wm5::Mathd::DEG_TO_RAD); Horizontal = Vertical.Cross(ToObject); Vertical = ToObject.Cross(Horizontal); if (0 == SliderId) { Wm5::Quaterniond RotateBy = Wm5::Quaterniond(Vertical, -0.008 * MovedAmount); m_Slide.GetSelectedObject().ModifyRotation() = RotateBy * m_Slide.GetSelectedObject().ModifyRotation(); // RotateBy first gives us rotations around global axes; RotateBy second gives us rotations around local axes m_Slide.GetSelectedObject().ModifyRotation().Normalize(); } else if (1 == SliderId) { Wm5::Quaterniond RotateBy = Wm5::Quaterniond(Horizontal, -0.008 * MovedAmount); m_Slide.GetSelectedObject().ModifyRotation() = RotateBy * m_Slide.GetSelectedObject().ModifyRotation(); // RotateBy first gives us rotations around global axes; RotateBy second gives us rotations around local axes m_Slide.GetSelectedObject().ModifyRotation().Normalize(); } else if (2 == SliderId) { Wm5::Vector3d ToObject = m_Slide.GetSelectedObject().GetPosition() - Wm5::Vector3d(camera.x, camera.y, camera.z); ToObject.Normalize(); Wm5::Quaterniond RotateBy = Wm5::Quaterniond(ToObject, 0.10 * MovedAmount); m_Slide.GetSelectedObject().ModifyRotation() = RotateBy * m_Slide.GetSelectedObject().ModifyRotation(); // RotateBy first gives us rotations around global axes; RotateBy second gives us rotations around local axes m_Slide.GetSelectedObject().ModifyRotation().Normalize(); } m_Slide.m_ModelRotatedByUser = true; } } }
void TBarView::Draw(BRect) { BRect bounds(Bounds()); rgb_color hilite = tint_color(ui_color(B_MENU_BACKGROUND_COLOR), B_DARKEN_1_TINT); rgb_color light = tint_color(ui_color(B_MENU_BACKGROUND_COLOR), B_LIGHTEN_2_TINT); SetHighColor(hilite); if (AcrossTop()) StrokeLine(bounds.LeftBottom(), bounds.RightBottom()); else if (AcrossBottom()) StrokeLine(bounds.LeftTop(), bounds.RightTop()); if (Vertical() && Expando()) { SetHighColor(hilite); BRect frame(fExpando->Frame()); StrokeLine(frame.LeftTop() + BPoint(0, -1), frame.RightTop() + BPoint(0, -1)); } }
void TBarView::Draw(BRect) { BRect bounds(Bounds()); rgb_color hilite = tint_color(ViewColor(), B_DARKEN_1_TINT); rgb_color light = tint_color(ViewColor(), B_LIGHTEN_2_TINT); SetHighColor(hilite); if (AcrossTop()) StrokeLine(bounds.LeftBottom(), bounds.RightBottom()); else if (AcrossBottom()) StrokeLine(bounds.LeftTop(), bounds.RightTop()); if (Vertical() && Expando()) { SetHighColor(hilite); BRect frame(fExpando->Frame()); StrokeLine(BPoint(frame.left, frame.top - 1), BPoint(frame.right, frame.top -1)); } }
void TBarView::HandleBeMenu(BMessage* messagewithdestination) { if (!Dragging()) return; // in mini-mode if (Vertical() && !Expando()) { // if drop is in the team menu, bail if (fBarMenuBar->CountItems() >= 2) { uint32 buttons; BPoint location; GetMouse(&location, &buttons); if (fBarMenuBar->ItemAt(1)->Frame().Contains(location)) return; } } if (messagewithdestination) { entry_ref ref; if (messagewithdestination->FindRef("refs", &ref) == B_OK) { BEntry entry(&ref, true); if (entry.IsDirectory()) { // if the ref received (should only be 1) is a directory // then add the drag refs to the directory AddRefsToBeMenu(DragMessage(), &ref); } else SendDragMessage(NULL, &ref); } } else { // adds drag refs to top level in be menu AddRefsToBeMenu(DragMessage(), NULL); } // clean up drag message and types list DragStop(true); }
Vertical vs_at(const double sz, const double t, const int eps, const double H) { if (t == 0) return Vertical::NoVerticalSolution; return Vertical((eps*H-sz)/t); }
namespace larcfm { Vertical::Vertical() { z = NaN; udef = true; } Vertical::Vertical(const double vz) { z = vz; udef = false; } bool Vertical::operator == (const Vertical& v) const { // strict equality return ! udef && ! v.udef && z==v.z; } bool Vertical::operator != (const Vertical& v) const { // strict disequality return !(*this == v); } const Vertical Vertical::NoVerticalSolution = Vertical(); Vertical Vertical::add_this(const double vz) { if (!udef) { z += vz; } return (*this); } bool Vertical::undef() const { return udef; } bool Vertical::almost_vertical_los(const double sz, const double H) { double absz = std::abs(sz); return !Util::almost_equals(absz,H) && absz < H; } // Computes times when sz,vz intersects rectangle of half height H // eps = -1 : larcfm::Entry // eps = 1 : larcfm::Exit double Vertical::Theta_H(const double sz, const double vz, const int eps, const double H) { if (vz == 0) // Weaker check should be done at the calling procedure return NaN; return (eps*sign(vz)*H-sz)/vz; } double Vertical::time_coalt(double sz, double vz) { if (vz == 0) // Weaker check should be done at the calling procedure return NaN; return -sz/vz; } Vertical vs_at(const double sz, const double t, const int eps, const double H) { if (t == 0) return Vertical::NoVerticalSolution; return Vertical((eps*H-sz)/t); } Vertical vs_only(const Vect3& s, const Vect2& v, const double t, const int eps, const double D, const double H) { Vect2 s2 = s.vect2(); if (eps*s.z < H && s2.sqv() > sq(D) && Horizontal::Delta(s2,v,D) > 0) return vs_at(s.z,Horizontal::Theta_D(s2,v,larcfm::Entry,D),eps,H); else if (eps*s.z >= H && t > 0) return vs_at(s.z,t,eps,H); return Vertical::NoVerticalSolution; } /* Solve the following equation on vz: * sz+t*vz = eps*H, * * where t = Theta_D(s,v,epsp). * eps determines the bottom, i.e.,-1, or top, i.e., 1, circle. */ Vertical Vertical::vs_circle(const Vect3& s, const Vect3& vo, const Vect3& vi, const int eps, const double D, const double H) { Vect2 s2 = s.vect2(); Vect2 vo2 = vo.vect2(); Vect2 vi2 = vi.vect2(); Vect2 v2 = vo2-vi2; if (vo2.almostEquals(vi2) && eps == sign(s.z)) return Vertical(vi.z); else if (Horizontal::Delta(s2,v2,D) > 0) return vs_only(s,v2,Horizontal::Theta_D(s2,v2,larcfm::Exit,D),eps,D,H).add_this(vi.z); return NoVerticalSolution; } Vertical Vertical::vs_circle_at(const double sz, const double viz, const double t, const int eps, const int dir, const double H) { if (t > 0 && dir*eps*sz <= dir*H) return vs_at(sz,t,eps,H).add_this(viz); return NoVerticalSolution; } Vertical Vertical::vs_los_recovery(const Vect3& s, const Vect3& vo, const Vect3& vi, const double H, const double t, int epsv) { if (t <= 0) return NoVerticalSolution; Vect3 v = vo-vi; double nvz = (epsv*H - s.z)/t; if (s.z*v.z >= 0 && std::abs(v.z) >= std::abs(nvz)) return Vertical(vo.z); else return Vertical(nvz+vi.z); } std::string Vertical::toString() { return " udef = ["+bool2str(udef)+" z = "+Fm2(z)+"]"; } }