single responsibility – Should a Car object be responsible for checking if it is able to run on certain Road objects?

I have 2 kinds of objects in my system, Car and Road.

A Car can be of various types and have properties like tire, tire size, engine, etc.

A Road can be of multiple types and have properties like terrain type, slippery, etc.

Some type of cars cannot ride on certain roads, based on the road properties and car limitations/constraints, like a common car cannot walk on beach sand because it would get stuck with smaller tires and weaker engine, but a “monster truck” could, because it has bigger tires and a better engine.

with that in mind, who should have the responsibility of checking whether a car can ride on a specific road?

i think that a Car should throw exceptions if it cannot ride, but i don’t think a Car should know in which road is going to ride.

  • should the road check the car’s properties and tell if it’s able to
    run on the road?
    i think this options falls to a procedural approach of getters/setters.

  • how would this scenario “scale” if a had multiple properties on a Car
    that could affect the capability of riding on a road?

how can i approach this?

base code:

export interface Car {
  engine: string;
  tire: string;
  tireSize: string;

  ride(): void // ride only if Road is compatible
}

export interface Road {
  terrain: string;
  isSlippery: boolean;
  cars: Car();

  startRace(): void
  
}

unity – Simulating Road Traffic/Overtaking – Overtake works mostly, but starts clipping other vehicle

I am trying to improve on my Car class, which is used to make a small road scene with 3 lanes each direction with the ability to overtake by changing lanes.

I had a very basic version working with all box colliders and a predictive movement script in my code (so basically I performed the movement of the object, then immediately check a collision and move it to previous_position in same frame). It worked OK but i found i was a bit clunky and I had to have oversized collision boxes on the car which caused me other problems elsewhere in the game.

Now I am using Raycast. At first I used just one Raycast from the centre of the car. But of course once the centre of the car had past the vehicle in front it would think road was clear. I tried to fix this by having 3 rays (centre, left, right in local space). This improved it a lot but the wingmirrors of the car (and often times a slice of the body) would clip into each-other.

I’ve ended up adding around 10 Raycasts trying to make sure it always sees the car in front. I even tried making the edge-most ones slightly past the width of the car.

The only thing I can think to mention is that the cars are rotated 90 degree. So transform.forward is actually facing either +/- X-Axis in world space depending on if isTopLane is true/false.

Here is the Car class in full. For the life of me I cannot figure out why the cars overtake but stop overtaking too early (ie. they continue straight through the edge of the car in front):

public class Car : MonoBehaviour
{
    bool isTopLane;
    float speed;

    float vehicle_width;
    float vehicle_length;
    Material material;



    AudioSource audioSource;
    float start_pitch;
    float max_pitch;

    float ray_length_forwards;
    float ray_length_sideways;



    public void InitCar(int spawn_z)
    {
        Color color = new Color(Random.Range(0f, 1f), Random.Range(0f, 1f), Random.Range(0f, 1f), 1);
        speed = Random.Range(Level_Road.car_speed_min, Level_Road.car_speed_max);
        

        if (spawn_z <= 0)
            isTopLane = false;
        else
            isTopLane = true;

        float x = -Level_Road.SPAWN_POSITION_X;
        Vector3 rot = Vector3.zero;
        rot.y = 90;
        if (isTopLane)
        {
            x *= -1;
            rot.y *= -1;
        }
            
        transform.position = new Vector3(x, 0, spawn_z);
        transform.eulerAngles = rot;
        
        material = GetComponentInChildren<MeshRenderer>().material;
        material.color = color;

        audioSource = GetComponent<AudioSource>();
        start_pitch = audioSource.pitch + (speed * 0.01f);
        max_pitch = start_pitch * 2.6f;


        vehicle_width = GetComponent<Collider>().bounds.size.x;
        vehicle_length = GetComponent<Collider>().bounds.size.z;
        ray_length_forwards = GetComponent<Collider>().bounds.size.z * 1.4f;
        ray_length_sideways = GetComponent<Collider>().bounds.size.x * 1.4f;

        if ((isTopLane && transform.position.z < 1.1f) || (!isTopLane && transform.position.z > -1.1f))
            speed = Level_Road.car_speed_max;

    }

    private void FixedUpdate()
    {
        if (GameManager.instance.Game_Paused)
            return;

        audioSource.enabled = GameManager.instance.Options_SoundOn;

        audioSource.pitch += (speed * 0.04f) * Time.fixedDeltaTime;
        if (audioSource.pitch > max_pitch)
            audioSource.pitch = start_pitch;

        Drive();
    }

    void Drive()
    {
        Vector3 centre = transform.position;
        Vector3 right1 = centre + Vector3.up * (vehicle_width * 0.1f);
        Vector3 right2 = centre + Vector3.up * (vehicle_width * 0.2f);
        Vector3 right3 = centre + Vector3.up * (vehicle_width * 0.3f);
        Vector3 right4 = centre + Vector3.up * (vehicle_width * 0.4f);
        Vector3 right5 = centre + Vector3.up * (vehicle_width * 0.5f);
        Vector3 right6 = centre + Vector3.up * (vehicle_width * 0.65f);
        Vector3 left1 = centre + Vector3.down * (vehicle_width * 0.1f);
        Vector3 left2 = centre + Vector3.down * (vehicle_width * 0.2f);
        Vector3 left3 = centre + Vector3.down * (vehicle_width * 0.3f);
        Vector3 left4 = centre + Vector3.down * (vehicle_width * 0.4f);
        Vector3 left5 = centre + Vector3.down * (vehicle_width * 0.5f);
        Vector3 left6 = centre + Vector3.down * (vehicle_width * 0.65f);
        Vector3() ray_origins = { centre, right1, right2, right3, right4, right5, right6, left1, left2, left3, left4, left5, left6 };
        for (int i = 0; i < ray_origins.Length; i++)
        {
            if (Physics.Raycast(new Ray(ray_origins(i), transform.forward), out RaycastHit hit, ray_length_forwards))
            {
                if (hit.transform.gameObject.GetComponent<Car>())
                {
                    Overtake();
                    return;
                }

            }
        }
        
        DriveForwards();

    }

    void DriveForwards()
    {
        Vector3 motion = transform.forward * speed * Time.fixedDeltaTime;
        transform.position += motion;
    }


    void Overtake()
    {
        if (isTopLane && transform.position.z <= 1)
            return;

        if (!isTopLane && transform.position.z >= -1)
            return;
        

        if (Physics.Raycast(new Ray(transform.position, -transform.right), out RaycastHit hit, ray_length_sideways))
        {
            if (hit.transform.gameObject.GetComponent<Car>())
                return;
        }

        Vector3 motion = -transform.right * speed * Time.fixedDeltaTime;
        transform.position += motion;
    }

}

Thank you for your time and help.

Where to find free printable road maps/atlases online?

I use ViaMichelin to plan my itineraries. The website is a bit more clumsy than Google Maps, but the itineraries and ancillary information are of a better quality. In ViaMichelin you also get maps. An overview maps of the whole trip as well as detailed maps for the different steps. These are the same maps as the Michelin maps you would buy on paper. Compared to Google, it is easier to zoom in and to print a given area.

The more difficult part is related to printing. It is hard to fit a whole trip on an A4 page. Even for a smaller trip, such as e.g. Brussels – Frankfurt/Main (+- 400km) it is hard to obtain a map that is still useable and readable. Moreover, if you take into consideration the price of colour ink or toner, apparently free maps come at a cost.

When it comes to long distance travel, my personal conclusion is that there are no (free) online resources, which might be able to compete with traditional maps and atlases. If you do not want to spend too much money on maps and atlases, you can do the following. There are road atlases covering Europe or parts of it. These are updated every year. When the updates are available or about to come out, the “older” ones are sold with huge discounts. These atlases are not “dernier cri” anymore, but remain very accurate and reliable. But, before a trip, you can always cross-check with ViaMichelin or alike.

Things are different if you are interested in local information. You can have destinaiton specific resources such as Get-a-map in the United Kingdom. As suggested in the comments, you might also be able to find free online maps made available by local tourist offices.

tips and tricks – What’s the cheapest item one can purchase at Dulles Airport in order to use the Dulles Access Road?

tips and tricks – What’s the cheapest item one can purchase at Dulles Airport in order to use the Dulles Access Road? – Travel Stack Exchange

python – how to plot curvature o road with road segment information?

I have the information of road segments and want to plot the curvature, but could not get reasonable results. I have this code:

import numpy as np

a = np.array((332 0 0 0 0 0 0 0)) # straight for first 5 sec
b = np.array((122 240 0 0 0 0 0)) # left for next 3 seconds
c = np.array((330 0 0 0 0 0 0 0)) # straight for next 5 seconds

plt.plot(a, b, c)
plt.show()

washington dc – Cheating the Dulles Access Road: How Do the Police Know?

Disclaimer: cheating by “backtracking” via the Dulles Access Road for non-airport business is illegal. I don’t do it, and you shouldn’t either.

I was recently introduced to the oddity that is the Dulles Access Road (DAR), a free, limited access road running from Falls Church, VA to Dulles Airport via the median of the busier Dulles Toll Road (DTR). The DAR is designated exclusively for airport traffic, while anyone can pay to use the DTR. As you might expect, this has lead to people cheating the system. When traffic is heavy on the DTR and/or other nearby highways, or if a driver doesn’t want to pay the toll, it is possible to take the DAR, loop through Dulles, and then exit the airport and proceed to the destination. Evidently this is enough of a problem that airport police and state patrol officers have started pulling people over who cheat. (source source)

My question is, how do police officers know that someone is cheating? Imagine a scenario where two people: Goodwin and Bradley live in Tysons, VA. Goodwin goes to the airport via the DAR to pick up his friend, and then they stop at the Burger King in Oak Hill, VA near the airport. This is a valid use of the DAR. Bradley goes to work at the Burger King in Oak Hill, and to avoid paying the toll (and possibly to save time during rush hour), uses the exact same route via the DAR and the arrivals loop at Dulles. How would the cops know to pull over Bradley’s car and not Goodwin’s? Their routes are identical, and if Goodwin’s friend is already out at the curb, their time in the airport will be similar.

For reference, here is the route that Goodwin and Bradley both took via the free DAR:
Route Goodwin and Bradley took via the Dulles Access Road

and here is the route that Bradley should have taken via the toll road:
Route Bradley should have taken via the Dulles Toll Road

Longest distance ordinary road sign?

Outside Narvik, Norway (at Gratangseidet north of Bjerkvik, at the border between Nordland and Troms) is a road sign indicating the distance to Kirkenes along the E6 as 1042 km:

Kirkenes 1042

Kirkenes 1042 km

Outside Murmansk/Му́рманск, along the M18, there is a road sign indicating the distance to Saint Petersburg/Санкт-Петерб́ург as 1382 km
(Google Streetview), and another one at 1434 km (presumably another route).

This forum post contains a photo of a sign indicating 2800 km to Perth.

I recall having seen a photograph of a road sign in Siberia, indicating ~5000 km-ish to Moscow, but I cannot find it now. However, this panoramio photo pictures 3177 km to Magadan / Магада́н.

What is the highest ordinary distance road sign in the world? By ordinary, I mean that special signs showing far-off cities don’t count; I mean only road signs part of ordinary distance signage.

There is some discussion on a skyscrapercity forum thread and a aaroads forum thread.

uk – Travelling from London Heathrow airport to Leeds Tempest Road

I am planning to land on 17th April at 7pm at London Heathrow Airport, mostly Terminal 2. I will have two checked bags, one laptop bag, and a carry-on bag.

I’m planning to prebook the National Express service from Heathrow to Leeds Tempest Road but have some questions:

  • what destination should I book? I don’t see Leeds Tempest Road in the National Express site.
  • Will we have enough space to keep the luggage in National Express?
  • Is any national express coach available after 9 pm towards Leeds?
  • Is it wise that I’m planning to prebook to avoid any delay when I arrive?
  • Heathrow has multiple starting points. Which one is the best?

Please advise. Also any other options?

driving – Specific Meaning of Restricted Usage Road on Google Maps

Google does not know why some roads are restricted or if they do know, they do not care.

In my area there is a big factory where there are through roads on the grounds, but nobody is allowed on the grounds but factory staff which has good reasons to be there. So also no off duty staff and usually the staff has to use the nearest entrance to where they need to be, not crossing the grounds for an exit on the far end.
Google does suggest using the roads through the factory grounds as ‘restricted roads’ at times.

On the other hand, a lot of roads in the Netherlands are through roads for cyclists but cars are only allowed for access. Most of the time there is a block in the road somewhere that can be taken out for emergency vehicles. Often those stay out for the gritting crew in winter.
Those roads will also show up in Google map routes with ‘restricted road’ warnings, even when you have the right to use them to reach an address on the road or use them on a bike without the restrictions affecting you.

So if Google mentions a restricted road you will have to check whether it affects you. Street view is a good help.
Something as big as a factory will show up on the map, with clear boundaries.
But a sign on the side of the road will not show up on the map, you can often get a clue on the satellite view as well as on street view if offered for the area.

But in some cases you just can not get information online and will have to sort out which part of the route is not available by checking out parts of the route and see where the warnings are for. And see if there are alternatives for that part of the route.

design – Do signs printed on the road offer a significant advantage for the user over signs on a post?

In Phoenix, we don’t have the MPH written on the road in our highways, but we do have the highway that this is an exit-only lane for written on the road. For example, you’re travelling on the 202W, and there’s an exit for the 101N coming up. Before the exit, there’s an on-ramp from another street and after that on-ramp (and before the exit) there’s an off-ramp for a different street.

Of course, there are signs above with yellow sections and black arrows pointing down at which lanes are for what–which is an exit-only for the new off-ramp, which are exit-only for the 101N, and which will allow you to continue on the 202W. I think it’s safe to say there’s a lot going on here.

In addition to this signage, there’s also writing in the lane that says:

101
N

or

202
W

as you drive along, so it’s clear that you’re in the proper (or improper!) lane. This is much more clear, and I think that of all the use cases for writing on the highway, this is probably one of the most useful.

I’ve tried to find a picture of it, but apparently all of us here in Phoenix take it for granted! 🙂

Next time I’m driving on the highway as a passenger I’ll try to snap a picture of it for you to see.

Anyway, it doesn’t have to do with speed limits, but it does have to do with a different kind of signage so I thought it might be interesting to chip in.

DreamProxies - Cheapest USA Elite Private Proxies 100 Cheapest USA Private Proxies Buy 200 Cheap USA Private Proxies 400 Best Private Proxies Cheap 1000 USA Private Proxies 2000 USA Private Proxies 5000 Cheap USA Private Proxies ExtraProxies.com - Buy Cheap Private Proxies Buy 50 Private Proxies Buy 100 Private Proxies Buy 200 Private Proxies Buy 500 Private Proxies Buy 1000 Private Proxies Buy 2000 Private Proxies ProxiesLive.com Proxies-free.com New Proxy Lists Every Day Proxies123.com Proxyti.com Buy Quality Private Proxies